views:

16

answers:

0

I want to show a tool tip for the element style (the non-editing mode) of a DataGridComboBoxColumn. I have not been able to figure out a good way of doing this. In the example below I can either show a tooltip, or allow edits to the cell by changing the IsHitTestVisible property to true or false. I have been unable to both show the tooltip when not editing and allow the initiation of editing mode. When hit test is true the tool tip works. When hit test is false the combo box will drop down.

What is the best way to get both editing and a tool tip?

<Window x:Class="WpfApplication2.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <DataGrid ItemsSource="{Binding}"
              AutoGenerateColumns="False"
              >
        <DataGrid.Columns>
            <DataGridComboBoxColumn Header="Yo">
                <DataGridComboBoxColumn.ElementStyle>
                    <Style TargetType="{x:Type ComboBox}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ComboBox">
                                        <TextBlock 
                                            Text="{TemplateBinding Text}"
                                            IsHitTestVisible="False"
                                            ToolTip="Yo"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </DataGridComboBoxColumn.ElementStyle>
            </DataGridComboBoxColumn>
        </DataGrid.Columns>
    </DataGrid>
</Grid>
</Window>



using System;
using System.Collections.Generic;
using System.Windows;

namespace WpfApplication2
{
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
        InitializeComponent();
        DataContext = new List<string> { "Hello" };
    }
  }
}