DataGridColumnHeaderまたはDataGridRowHeaderのスタイルを作成し、ContentTemplateをHeaderプロパティをバインドできるDataTemplateに設定できます。このためにはバインディングを有効にするIValueConverterが必要です。
ヘッダはControls.Primitives名前空間にあります。
xmlns:dp="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
スタイル:
<Style TargetType="dp:DataGridColumnHeader" >
<Setter Property="ContentTemplate" >
<Setter.Value>
<DataTemplate>
<ContentPresenter Content="{Binding Converter={StaticResource vcBC}}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
コンバータ:
public class BindingConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value.GetType().Name == "Binding")
{
ContentControl cc = new ContentControl();
cc.SetBinding(ContentControl.ContentProperty, value as Binding);
return cc;
}
else return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
コンバーターインスタンス:
<yourassembly:BindingConverter x:Key="vcBC"/>
応答に感謝しますが、部分的には役立ちますが、問題に関する多くの疑問が残ります。まだ見ています... – Vin
さて、残りの質問にお答えください:-) –