Xaml 在uwp中的fontIcon上添加下拉菜单
我目前正在处理一个具有自定义标题栏的项目,该标题栏是使用中的示例创建的。通过这个例子,我可以创建一个类似的菜单。到目前为止,自定义标题条形码如下所示Xaml 在uwp中的fontIcon上添加下拉菜单,xaml,winrt-xaml,win-universal-app,windows-10-universal,Xaml,Winrt Xaml,Win Universal App,Windows 10 Universal,我目前正在处理一个具有自定义标题栏的项目,该标题栏是使用中的示例创建的。通过这个例子,我可以创建一个类似的菜单。到目前为止,自定义标题条形码如下所示 <Border x:Name="customTitleBar" VerticalAlignment="Top" Height="32" Background="Transparent" FlyoutBase.AttachedFlyout="{StaticResource FlyoutBase1}"> <Stac
<Border x:Name="customTitleBar" VerticalAlignment="Top" Height="32" Background="Transparent" FlyoutBase.AttachedFlyout="{StaticResource FlyoutBase1}">
<StackPanel Margin="12,5,5,5" Orientation="Horizontal">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""
Foreground="Black" VerticalAlignment="Center" Margin="12,0,8,0">
</FontIcon>
<TextBlock Text="My app" Foreground="Black"
VerticalAlignment="Center" Margin="25,0"/>
</StackPanel>
<i:Interaction.Behaviors>
<local:TitleBarBehavior IsChromeless="True"/>
</i:Interaction.Behaviors>
</Border>
注意:汉堡图标与上面的fontIcon一起插入。与上面的图片类似,我希望在下拉列表中有一个共享和设置命令。我还是Windows10UWP的新手,有没有办法把FontIcom包装成一个菜单控件,我知道这听起来不对?我还尝试在XAML中指定的指针上更改fontIcon的颜色,如何在不将事件定义放在代码后面的情况下实现这一点?>是否有办法将FontIcom包装在MenuFlyout控件中
你的意思是想在菜单中添加FontIcon,就像我用红色突出显示的一样
如果是这样,最好使用而不是MenuFlyout,因为默认情况下MenuFlyout将有许多带有文本属性(字符串值)的MenuFlyoutItems,这样我们就不能在MenuFlyout中添加FontIcon等控件
有关如何使用来实现您的要求,请尝试参考:
<Flyout>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" Foreground="Black"/>
<TextBlock Text="Share"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" Foreground="Black"/>
<TextBlock Text="Settings"></TextBlock>
</StackPanel>
</StackPanel>
</Flyout>
结果是:
>我还尝试更改XAML中指针上fontIcon的颜色,如何在不将事件定义放在代码后面的情况下实现这一点?
对于这个问题,请在您的另一个帖子中查看我的答复:
谢谢。在搜索互联网并阅读弹出式菜单后。Fang answer抛出错误“不能将弹出型按钮的值添加到集合或UIElementCollection元素。弹出型按钮菜单只能添加到按钮。弹出型按钮属性根据 为了解决我的问题,我改进了方答案。重新实现如下所示
<Button FontFamily="Segoe MDL2 Assets" Content=""
Foreground="Black" VerticalAlignment="Center" Margin="12,0,8,0" Background="Transparent">
<Button.Flyout>
<Flyout>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" Foreground="Black"/>
<TextBlock Text="Share" Margin="5,0"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<FontIcon Margin="0,5" FontFamily="Segoe MDL2 Assets" Glyph="" Foreground="Black"/>
<TextBlock Text="Settings" Margin="5,5"></TextBlock>
</StackPanel>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
谢谢@Fang,我已经解决了这个问题,并对您的代码进行了修改。根据我上面的解释,仅使用您的代码就产生了一个错误。