如何使用Style将DataTemplate添加到用于wpf ComboBox的ToolTip

时间:2010-10-06 01:18:39

标签: wpf combobox tooltip datatemplate

我正在尝试在ComboBox中格式化工具提示。以下XAML正确地获取了ToolTip所需的值,而不是DataTemplate。

<DataTemplate DataType = "ToolTip">
            <TextBlock Width = "200" TextWrapping = "Wrap" Text = "{Binding}" />
        </DataTemplate>
        <Style x:Key = "RadComboBoxStyle1" TargetType = "{x:Type telerik:RadComboBox}">         
            <Setter Property = "Width" Value = "140" />
            <Setter Property = "DisplayMemberPath" Value = "DisplayMember" />
            <Setter Property = "SelectedValuePath" Value = "SelectedValue" />
            <Setter Property = "ToolTip" Value = "{Binding RelativeSource={RelativeSource Mode=Self}, Path=SelectedItem.Description}" />
        </Style>

我确信它不会像我做的那样困难:)

由于 杰里米

1 个答案:

答案 0 :(得分:1)

您可以使用

定义工具提示
<ComboBox>
    <ComboBox.ToolTip>
       <!-- custom tip -->
    </ComboBox.ToolTip>
</ComboBox>

但也许可以尝试:

<DataTemplate DataType="{x:Type ToolTip}">