图像而不是符号SplitView.窗格项目图标
本文关键字:项目 图标 SplitView 符号 图像 | 更新日期: 2023-09-27 18:14:25
我想使用图像(PNG)将其设置为SplitView的图标。面板项目。没有图标,在Sagoe MDL2字体。我知道建议使用矢量字体,但我真的需要用png图像替换它。下面是它现在的工作方式:
XAML…
<SplitView.Pane>
<!-- A custom ListView to display the items in the pane. The automation Name is set in the ContainerContentChanging event. -->
<controls:NavMenuListView x:Name="NavMenuList"
TabIndex="3"
Margin="0,48,0,0"
ContainerContentChanging="NavMenuItemContainerContentChanging"
ItemContainerStyle="{StaticResource NavMenuItemContainerStyle}"
ItemTemplate="{StaticResource NavMenuItemTemplate}"
ItemInvoked="NavMenuList_ItemInvoked">
</SplitView.Pane>
向导航列表添加项目代码:
private List<NavMenuItem> navlist = new List<NavMenuItem>(
new[]
{
new NavMenuItem()
{
Symbol = Symbol.Shop,
Label = "Go to shop",
DestinationPage = typeof(Views.Page1)
}
});
和NavMenuItem
类:
public class NavMenuItem
{
public string Label { get; set; }
public Symbol Symbol { get; set; }
public char SymbolAsChar
{
get
{
return (char)this.Symbol;
}
}
public Type DestinationPage { get; set; }
public object Arguments { get; set; }
}
还有一个问题,不要打开另一个话题。如何像在Windows 10邮件应用程序中那样在设置按钮上打开左侧窗格?谢谢。
使用uri代替符号
public Uri IconUri {get; set;}
和在NavMenuItemTemplate
中使用Image
并将其Source
属性绑定到IconUri
。
要打开窗格,只需将IsPaneOpen设置为true。
splitView.IsPaneOpen = true;