[英]UNO Material BottomNavigationBar Event Handler
I am implementing the BottomNavigationBar from Uno.Material in my app.我正在我的应用程序中实现来自 Uno.Material 的 BottomNavigationBar。 I can get the bar to appear like I want it to- but can not figure out what the event handler is for when I click on a bottomnavigationbaritem to change it.
我可以让栏看起来像我想要的那样 - 但是当我单击底部导航栏项来更改它时,无法弄清楚事件处理程序的用途。 I have tried ItemInvoked, OnPressed, OnTouch, OnClick, Clicked- but not able to get it to work.
我尝试过 ItemInvoked、OnPressed、OnTouch、OnClick、Clicked-但无法让它工作。 I am a bit embarrassed to ask- but would someone be able to point me in the right direction of what event is fired and what the method signature of the event should be?
我有点不好意思问 - 但有人能指出我正确的方向,什么事件被触发以及事件的方法签名应该是什么?
... <controls:BottomNavigationBar x:Name="BottomNavBar" Grid.Row="2"mOnClick="BottomNavView_ItemInvoked"> ... ... <controls:BottomNavigationBar x:Name="BottomNavBar" Grid.Row="2"mOnClick="BottomNavView_ItemInvoked"> ...
BottomNavigationBar
does not expose an ItemInvoked
event. BottomNavigationBar
不公开ItemInvoked
事件。 You can retrieve the current selection via the SelectedItem
property.您可以通过
SelectedItem
属性检索当前选择。 I suppose it could also offer a ItemInvoked
option like NavigationView
is offering, feel free to open an issue here with your suggestion.我想它也可以提供一个
ItemInvoked
选项,就像NavigationView
所提供的那样,请随时根据您的建议在此处打开一个问题。
However, BottomNavigationBarItem
is a ToggleButton
, so it implements the Click
, Checked
and Unchecked
events already.但是,
BottomNavigationBarItem
是一个ToggleButton
,因此它已经实现了Click
、 Checked
和Unchecked
事件。
Here's an example of how you could handle those events in your app.下面是如何在应用程序中处理这些事件的示例。 (You probably only need
Checked
, depending on your scenario) (您可能只需要
Checked
,具体取决于您的情况)
<controls:BottomNavigationBar>
<controls:BottomNavigationBar.Items>
<controls:BottomNavigationBarItem Label="Favorites"
Click="OnClick"
Checked="OnChecked"
Unchecked="OnUnChecked">
<controls:BottomNavigationBarItem.Icon>
<SymbolIcon Symbol="Favorite" />
</controls:BottomNavigationBarItem.Icon>
</controls:BottomNavigationBarItem>
[...insert more items...]
</controls:BottomNavigationBar.Items>
</controls:BottomNavigationBar>
public void OnClick(object sender, object args)
{
var navBarItem = sender as BottomNavigationBarItem;
// Add logic here
}
public void OnChecked(object sender, object args)
{
var navBarItem = sender as BottomNavigationBarItem;
// Add logic here
}
public void OnUnChecked(object sender, object args)
{
// Items are automatically unchecked when another one is checked.
var navBarItem = sender as BottomNavigationBarItem;
// Add logic here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.