【发布时间】:2017-09-05 18:41:34
【问题描述】:
我正在使用 syncfusion: menuItemAdv 控件来显示应用程序的分层菜单项。 OnMouseOver 或 OnMouseClicked(ExpandMode 属性)它在鼠标悬停菜单项时显示子项。但它不会在鼠标离开时消失该列表。但是,如果我单击窗口上的其他任何位置(可能失去焦点),那么它会清除子菜单项。
所以,与其清除失去焦点的子菜单项。我想在鼠标离开时这样做,因为用户可能会打开任何其他应用程序而不会导致失去焦点事件并且可能会感到困惑。所以,我想在鼠标离开时清除项目列表。
我知道,我可以编写一个行为并且可以在鼠标离开事件上挂钩它,但我不知道如何清理该列表。因为该库没有公开任何方法。与物品来源调和可能会搞砸一些事情。
感谢任何帮助。
xaml如下
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainWindowVM></local:MainWindowVM>
</Window.DataContext>
<Grid>
<syncfusion:MenuAdv Width="300" Height="40" ItemsSource="{Binding League}" ExpandMode="ExpandOnMouseOver">
<syncfusion:MenuAdv.ItemTemplate >
<HierarchicalDataTemplate DataType="local:MenuList" ItemsSource="{Binding Teams}" >
<StackPanel Orientation="Vertical" VerticalAlignment="Top" >
<Label Content="{Binding Name}" Height="Auto" FontFamily="Arial" FontSize="12" VerticalAlignment="Top" Margin="0,3,0,0" VerticalContentAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</syncfusion:MenuAdv.ItemTemplate>
</syncfusion:MenuAdv>
</Grid>
</Window>
【问题讨论】:
-
您的应用中是否允许使用代码隐藏功能?
-
我可以设法让以后我可以把它变成行为
标签: c# .net wpf xaml syncfusion