2009-11-14 6 views
10

나는 다음 시도했다.수 없습니다

아이디어가 있으십니까? 구현 된 것입니까? 여기

<DataGridTextColumn Width="SizeToCells" 
        MinWidth="150" 
        Binding="{Binding Name}"> 

    <DataGridTextColumn.Header> 
     <TextBlock Text="Name" ToolTipService.ToolTip="Header ToolTip" /> 
    </DataGridTextColumn.Header> 

    <DataGridTextColumn.ElementStyle> 
     <Style TargetType="{x:Type TextBlock}"> 
      <Setter Property="ToolTip" Value="{Binding Description}" /> 
      <Setter Property="TextWrapping" Value="Wrap" /> 
     </Style> 
    </DataGridTextColumn.ElementStyle> 
</DataGridTextColumn> 

솔루션 : 아래의 코드는 당신을 위해 작동 할 경우

답변

24

이 나를 위해 작동합니다

<Style TargetType="{x:Type Custom:DataGridColumnHeader}"> 
    <Style.Triggers> 
     <Trigger Property="IsMouseOver" Value="True"> 
      <Setter Property="ToolTip" Value="{Binding Column.(ToolTipService.ToolTip), RelativeSource={RelativeSource Self}}"/> 
     </Trigger> 
    </Style.Triggers> 
</Style> 
+0

브릴리언트! 이 작은 스타일 덕분에 도구 설명이 나타나게되어 DataGridColumnHeaders를 DataGridTextColumns 또는 다른 것으로 변경해야하는 번거 로움이 없습니다. 정확히 내가 무엇을 찾고 있었는지! –

+0

위의 스타일을 DataGridComboBoxColumn에 추가하는 방법을 말해 줄 수 있습니까? – Abhi

4

DataGridTextColumn이 표시되지 않습니다. 헤더 나 내용에 툴팁을 설정해야합니다. ,

<tk:DataGridTextColumn 
    Binding="{Binding Item.Title}"> 
    <tk:DataGridTextColumn.Header> 
    <TextBlock 
     Text="Text" 
     ToolTipService.ToolTip="Tooltip for header" /> 
    </tk:DataGridTextColumn.Header> 
</tk:DataGridTextColumn> 

이 열 내용에 대한 도구 설명을 설정하려면 스타일에서 설정 :

는 TextBlock에에 머리글을 변경, 헤더에 도구 설명을 설정하려면

<tk:DataGridTextColumn 
    Binding="{Binding Item.Title}" 
    Heading="Text"> 
    <tk:DataGridTextColumn.ElementStyle> 
    <Style> 
     <Setter Property="ToolTipService.ToolTip" Value="{Binding Item.Description}" /> 
    </Style> 
    </tk:DataGridTextColumn.ElementStyle> 
</tk:DataGridTextColumn> 

당신은 할 수있다 EditingElementStyle도 설정하고 싶습니다.

0

설정 ToolTipService.ToolTip 재산권 머리글 스타일 : 여기

<Setter Property="ToolTipService.ToolTip" Value="{x:Static res:StringResources.List_Dialog_SelectAll_Checkbox}"/> 

그것이 내가 DataGridCheckBoxColumn 대신 텍스트에서 이미지를했을 때 내가 그것을 사용하는 방법입니다. XAML :

<Window x:Class="MyProject.GUI.ListDialog" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:viewModel="clr-MyProject.GUI.ViewModels" 
      Title="{Binding Title}" Height="350" Width="650" 
      MinHeight="350" MinWidth="650" 
      xmlns:res="clr-MyProject.GUI.Resources" Closing="Window_Closing" WindowStyle="ToolWindow"> 
    <Window.Resources> 
      <BitmapImage x:Key="MyImageSource" UriSource="Resources/Images/SelectDeselect.png" /> 
      <Style x:Key="CheckBoxHeader" TargetType="DataGridColumnHeader"> 
       <Setter Property="HorizontalContentAlignment" Value="Center"/> 
       <Setter Property="VerticalContentAlignment" Value="Center"/> 
          <Setter Property="ToolTipService.ToolTip" Value="{x:Static res:StringResources.List_Dialog_SelectAll_Checkbox}"/> 
       <Setter Property="ContentTemplate"> 
        <Setter.Value> 
         <DataTemplate> 
          <Image Width="15" Height="15" Source="{StaticResource MyImageSource}" /> 
         </DataTemplate> 
        </Setter.Value> 
       </Setter> 
      </Style> 
    </Window.Resources> 

C 번호 : 당신의 열이 대신 DataGridTextColumn의 DataGridTemplateColumn 경우

DataGridCheckBoxColumn checkColumn = new DataGridCheckBoxColumn(); 
checkColumn.HeaderStyle = new System.Windows.Style(); 
checkColumn.CanUserSort = checkColumn.CanUserResize = false; 
checkColumn.Width = new DataGridLength(25); 
checkColumn.HeaderStyle = (Style)Resources["CheckBoxHeader"]; 
checkColumn.CellStyle = (Style)Resources["CenterAlignedCellStyle"]; 
checkColumn.IsReadOnly = false; 
dataGrid.Columns.Add(checkColumn); 
1

또한, 당신이 이런 식으로 작업을 수행 할 수 있습니다

<DataGridTemplateColumn x:Name="MyCheckBoxColumn" CellStyle="{StaticResource MyCellStyle}" > 
    <DataGridTemplateColumn.HeaderTemplate> 
     <DataTemplate> 
      <TextBlock Text="MyHeaderName" ToolTip="This is my column description" /> 
     </DataTemplate> 
    </DataGridTemplateColumn.HeaderTemplate> 
    <DataGridTemplateColumn.CellTemplate> 
     <DataTemplate> 
      <CheckBox ... /> 
     </DataTemplate> 
    </DataGridTemplateColumn.CellTemplate> 
</DataGridTemplateColumn> 
관련 문제