views:

62

answers:

2

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

+1  A: 

You could just define the tooltip with

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

but otherwise maybe try:

<DataTemplate DataType="{x:Type ToolTip}">
Val
That doesn't work. I really want to do it within the style - I've got about 20 comboboxes on the form, and would rather change them universally from within the style than have to touch each one.
Jeremy Holt
A: 

Here is example how to reuse ToolTips that have databinding.

Lukas Cenovsky