ฉันต้องการ ApplicationBar ที่สามารถผูกไว้กับทั้งคำสั่งและเหตุการณ์การแตะ (จำเป็นต้องมีเหตุการณ์การแตะสำหรับสิ่งที่เกี่ยวข้องกับ UI และฉันไม่สามารถจัดการได้ในโมเดลของฉัน)
ฉันกำลังลองใช้ BindableApplicationBar จาก NuGet และการผูกคำสั่งทำงานได้ดี แต่ไม่มีวิธีรับเหตุการณ์การแตะ
โปรดทราบว่าฉันกำลังเปลี่ยน DataContext
เพื่อให้การเชื่อมโยงใช้งานได้ แต่เหตุการณ์ Tap
จะต้องได้รับการจัดการในโค้ดที่อยู่เบื้องหลัง (และฉันไม่รู้ว่านี่อาจเป็นสาเหตุหลักของปัญหาของฉันหรือไม่!)
นี่คือ xaml ของบาร์:
<bindableApplicationBar:Bindable.ApplicationBar>
<bindableApplicationBar:BindableApplicationBar>
<bindableApplicationBar:BindableApplicationBarButton
Text="{Binding MainSearchText}"
IconUri="Assets/AppBar/feature.search.png"
Command="{Binding NavigateCommand}"
Name="SearchBarButton" />
<bindableApplicationBar:BindableApplicationBarButton
Text="{Binding Path=LocalizedResources.AppBarSettingsText, Source={StaticResource LocalizedStrings}}"
IconUri="Assets/AppBar/feature.settings.png"
Tap="SettingsButton_OnTap" />
<bindableApplicationBar:BindableApplicationBar.MenuItems>
<bindableApplicationBar:BindableApplicationBarMenuItem
Text="{Binding Path=LocalizedResources.AppBarAboutText, Source={StaticResource LocalizedStrings}}"
Tap="Info_OnTap" />
</bindableApplicationBar:BindableApplicationBar.MenuItems>
</bindableApplicationBar:BindableApplicationBar>
</bindableApplicationBar:Bindable.ApplicationBar>
และนี่คือหนึ่งในตัวจัดการที่ฉันมีในไฟล์ .xaml.cs:
private void Info_OnTap(object sender, GestureEventArgs e)
{
_about.Show();
Debug.WriteLine("INFO ON_TAP");
}
ไม่มีการเขียนบรรทัด "INFO ON_TAP" เมื่อฉันคลิกที่ MenuItem
มีอะไรผิดปกติกับมัน?