私はWPFで作業しており、HeaderedContentControlのヘッダーのテキストとツールチップを設定する必要があります。だから私がやろうとしているのは、以下のようなテンプレートを作成することです。
System.Windows.DataTemplate template = new System.Windows.DataTemplate();
template.DataType = typeof(HeaderedContentControl);
System.Windows.FrameworkElementFactory blockFactory = new System.Windows.FrameworkElementFactory(typeof(TextBlock));
blockFactory.SetValue(TextBlock.TextProperty, "The Header Text");
blockFactory.SetValue(TextBlock.ToolTipProperty, "The ToolTip");
template.VisualTree = blockFactory;
myHeaderedContentControl.HeaderTemplate = template;
しかし、プログラムを実行すると、ヘッダーが空で表示されます。私は何が間違っているのですか?
誰かが助けてくれることを願っています、よろしくお願いします