설정 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);
브릴리언트! 이 작은 스타일 덕분에 도구 설명이 나타나게되어 DataGridColumnHeaders를 DataGridTextColumns 또는 다른 것으로 변경해야하는 번거 로움이 없습니다. 정확히 내가 무엇을 찾고 있었는지! –
위의 스타일을 DataGridComboBoxColumn에 추가하는 방법을 말해 줄 수 있습니까? – Abhi