我知道这个问题已经被问过无数次了,但我不明白他们的问题是什么或如何效仿他们的例子。我确实找到了她的名字雷切尔,发布了一篇关于它的博客,但她的解释太简短了..
这是我在尝试遵循此处示例之前所拥有的:
<Window x:Class="Graph.View.MainView.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
Title="Main" Height="350" Width="525"
xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking">
<DockPanel LastChildFill="True">
<DockPanel>
<Label Content="{Binding ScreenContent}" Grid.Row="1" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
</DockPanel>
</DockPanel>
因为ScreenContent
有一个合乎逻辑的父母我不能重用它。在尝试遵循 Rachel 的示例之后:
<Window x:Class="Graph.View.MainView.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
Title="Main" Height="350" Width="525"
>
<Window.Resources>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<DockPanel>
<Label Content="{Binding ScreenContent}" Grid.Row="1" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
</DockPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<DockPanel LastChildFill="True">
<Label Style="{StaticResource MyCustomContentControl}"/>
</DockPanel>
</Window>
我该如何解决?它根本没有显示任何东西......谢谢。