1
私はここで何が欠けているのか分かりません。 ContentPresenterのコンテンツをUIElementにバインドしたいと思います。私が直接でのTextBlockを置くことができますが、私はそれが何も表示されないのContentPresenterをしようとすると、MainWindow.cscontentPresenterのコンテンツをバインドできません
UIElement Element { get; set; }
public MainWindow()
{
Element = new TextBox() { Text = "A" };
DataContext = this;
InitializeComponent();
}
で
<Window.Resources>
<DataTemplate x:Key="container">
<Border>
<!--<TextBlock Text="A"/>-->
<ContentPresenter Content="{Binding Element}" />
</Border>
</DataTemplate>
</Window.Resources>
<ContentControl DataContext="{Binding}" ContentTemplate="{StaticResource container}" />
:私はこのような何かをやっています。
よく置いてください!最初の問題は '要素'が公開されていないことです。第2の問題は、ContentControlに 'Content'がなく、したがってContentTemplateにテンプレートを使用するコンテンツがないことです。 – Scott