Xamarin.forms 如何在导航栏中引用barItem并更改图标
比如说,第1页和第2页的图标数量与下面相同 (1) 第1页Xamarin.forms 如何在导航栏中引用barItem并更改图标,xamarin.forms,Xamarin.forms,比如说,第1页和第2页的图标数量与下面相同 (1) 第1页 它有4个这样的图标 1a)默认情况下,itemIcon1.png当前处于选中状态,它具有暗色调图标以显示它是当前选中的图标。 1b)其他图标没有深色色调,这表明它们未被选中。 在第1页,选中并单击ItemIcon2.png后,它将导航到第2页 (2) 在第2页。 2a)itemIcon2.png将有一个深色色调,表明它是当前选定的图标。 2b)其他没有暗色的图标 问题: 当导航到第1页到第2页时,如何引用MenuItem2并将图标从
- 它有4个这样的图标
1b)其他图标没有深色色调,这表明它们未被选中。
在第1页,选中并单击ItemIcon2.png后,它将导航到第2页 (2) 在第2页。
2a)itemIcon2.png将有一个深色色调,表明它是当前选定的图标。
2b)其他没有暗色的图标
问题: 当导航到第1页到第2页时,如何引用MenuItem2并将图标从LightTone图标更改为DarkTone图标(例如itemIcon2Dark.png)
Page1和Page2将具有相同数量的图标
谢谢每页都有工具栏。为什么不使用不同的图像?例如,在第1页上,图像icon2将为黑色,在第2页上,图像icon2将为icon2_light。在第1页上,用户可以选择其余3个图标中的任意一个。比如说,icon2在第1页是浅色调的,当用户选择它并导航到第2页时,这个icon2会有深色调的图标来显示它是选中的。再说一次,问题是什么?每个页面都有自己的工具栏。你预先知道在哪一页上应该有什么图标,不是吗?
Page1 and Page2 will have the same number of icons
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title="CheckList"
x:Class="mmy.View.MainPage">
<ContentPage.ToolbarItems>
<ToolbarItem Name="MenuItem1" Order="Primary" Icon="itemIcon1.png" Priority="0" />
<ToolbarItem Name="MenuItem2" Order="Primary" Icon="itemIcon2.png" Priority="1" />
<ToolbarItem Name="MenuItem3" Order="Primary" Icon="itemIcon3.png" Priority="2" />
<ToolbarItem Name="MenuItem4" Order="Primary" Icon="itemIcon4.png" Priority="3" />
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<Label Text="Page1"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>