Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 为什么我的工具提示不显示为列表框_Wpf_Xaml - Fatal编程技术网

Wpf 为什么我的工具提示不显示为列表框

Wpf 为什么我的工具提示不显示为列表框,wpf,xaml,Wpf,Xaml,当我使用以下内容时,我会看到一个工具提示,但不是显示为ListView,而是显示为单个工具提示System.Window.DataTemplate 我想我已经解释了使用什么数据模板。。。为什么下面不显示DataTemplate的结果,而只显示“类型” <DataTemplate DataType="{x:Type ToolTip}" x:Key="Tool"> <ListView DataContext="{Binding Path=MyMix}" ItemsS

当我使用以下内容时,我会看到一个工具提示,但不是显示为ListView,而是显示为单个工具提示System.Window.DataTemplate

我想我已经解释了使用什么数据模板。。。为什么下面不显示DataTemplate的结果,而只显示“类型”

<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>