问题
我写了一个用户控件:
<UserControl ...>
<UserControl.Resources>
...
</UserControl.Resources>
<UserControl.Template>
<ControlTemplate>
<Grid>
<Border x:Name="BorderX" BorderBrush="Gray" Style="{ms:MultiStyle EffectBorder BorderRegion}" >
<Grid>
<TextBlock x:Name="XBorderTitle" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:XBorder}},Path=Title}" TextWrapping="Wrap" Style="{StaticResource BorderTitle}"/>
<ContentPresenter Content="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:XBorder}},Path=Content}"/>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</UserControl.Template>
</UserControl>
然后,我在主窗体中添加:
<mll:XBorder Margin="20,20,20,100" Title="About" BorderBrush="Gray">
<mll:XBorder.Content>
<Grid>
<TextBlock Text="test"/>
</Grid>
</mll:XBorder.Content>
</mll:XBorder>
但是Border
无法正常显示,是我写的Template
写的有问题吗?还是其他的问题?