Wpf 为什么我的工具提示不显示为列表框
当我使用以下内容时,我会看到一个工具提示,但不是显示为ListView,而是显示为单个工具提示System.Window.DataTemplate 我想我已经解释了使用什么数据模板。。。为什么下面不显示DataTemplate的结果,而只显示“类型”Wpf 为什么我的工具提示不显示为列表框,wpf,xaml,Wpf,Xaml,当我使用以下内容时,我会看到一个工具提示,但不是显示为ListView,而是显示为单个工具提示System.Window.DataTemplate 我想我已经解释了使用什么数据模板。。。为什么下面不显示DataTemplate的结果,而只显示“类型” <DataTemplate DataType="{x:Type ToolTip}" x:Key="Tool"> <ListView DataContext="{Binding Path=MyMix}" ItemsS
<DataTemplate DataType="{x:Type ToolTip}" x:Key="Tool">
<ListView DataContext="{Binding Path=MyMix}" ItemsSource="{Binding Path=Mix}" ItemTemplate="{StaticResource MyTemplate}" />
</DataTemplate>
<DataTemplate x:Key="MyButtons">
<StackPanel>
<ComboBox SelectedIndex="{Binding Path=MyIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" ItemsSource="{Binding Path=MyCollection}" DisplayMemberPath="Name" Binding.SourceUpdated="ComboBox_SourceUpdated" ToolTip="{StaticResource Tool}">
</ComboBox>
</StackPanel>
</DataTemplate>
在我看来,您没有实例化
工具提示的实例,因此不会创建任何实例。(模板不实例化工具提示
,而在组合框中,只有对工具提示
属性的赋值,该属性有效地调用了数据模板
类的类型转换器。)
我试过这个密码
<Grid.Resources>
<DataTemplate DataType="{x:Type MyMix}">
<ToolTip>
<ListView ItemsSource="{Binding Mix}"></ListView>
</ToolTip>
</DataTemplate>
</Grid.Resources>
<StackPanel>
<ComboBox ItemsSource="{Binding MyCollection}" DisplayMemberPath="Name">
<ComboBox.ToolTip>
<ListView ItemsSource="{Binding Path=MyMix.Mix}" ></ListView>
</ComboBox.ToolTip>
</ComboBox>
</StackPanel>