Jeremy Holt
Jeremy Holt

Reputation: 325

How to add a DataTemplate to a ToolTip for a wpf ComboBox using a Style

I am trying to format a ToolTip in a ComboBox. The following XAML is correctly picking up the value needed for the ToolTip, but not the 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>

I'm sure it can't be as difficult as I'm making it :)

Thanks Jeremy

Upvotes: 1

Views: 6869

Answers (1)

Val
Val

Reputation: 930

You could just define the tooltip with

<ComboBox>
    <ComboBox.ToolTip>
       <!-- custom tip -->
    </ComboBox.ToolTip>
</ComboBox>

but otherwise maybe try:

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

Upvotes: 1

Related Questions