【问题标题】:Add Navigation Arrows to Menu将导航箭头添加到菜单
【发布时间】:2012-10-09 08:11:49
【问题描述】:

我希望在我的系统中实现以下箭头设计,其中箭头位于所选项目上。

目前我已经将菜单实现为 ​​ListBox 并且行为正确,减去了箭头。 实现这种行为的最佳方法是什么?

目前,我已经编辑了 ItemsControl 并添加了一个箭头,但它在边框内,而不是在边框外,如下所示:

<ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid>
                        <Border Name="Border">
                            <ContentPresenter Content="{TemplateBinding Content}" />
                        </Border>
                        <Path Name="SelectedArrow" Data="{StaticResource RightArrow}" Width="10" Height="20" Stretch="Fill" Fill="White" HorizontalAlignment="Right" Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="SelectedArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>

【问题讨论】:

    标签: c# wpf xaml user-interface navigation


    【解决方案1】:

    覆盖它的 ItemTemplate 以包含一个箭头并将其可见性设置在可以检查 IsSelected 条件的触发器上。

    【讨论】:

    • 我不确定如何将箭头设置在列表框的“外部”。我在 ListBoxItem 的 ItemControl 中实现了以下内容: <grid><border name="Border" height="23" minwidth="190"><contentpresenter content="{TemplateBinding Content}" verticalalignment="Center" margin="20,0,0,0"></contentpresenter></border><image source="/Resources/Images/NavArrow.png" stretch="None" horizo></image></grid> 我尝试设置边距,但它只是让箭头消失了。
    猜你喜欢
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 2018-05-17
    相关资源
    最近更新 更多