到目前为止,我有这个:
<UserControl
x:Class="MyConcept.ExpanderPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Border
Style="{StaticResource Border_PanelStyle}"
CornerRadius="3" />
<ContentPresenter />
</Grid>
</UserControl>
此 UserControl 的示例用法:
<nc:ExpanderPanel
Grid.Row="0">
<Expander
IsExpanded="True"
Header="NMT Users">
<StackPanel>
...
</StackPanel>
</Expander>
</nc:ExpanderPanel>
讨论
如果我运行它,我什么也看不到。没有显示任何内容,甚至没有显示在 UserControl 中的边框。
我想也许我需要创建ContentPresenter
一个依赖属性,但我不知道如何将该属性链接到 UserControl 的 XAML 中的 ContentPresenter。
有人可以提供一个简单的示例来说明如何UserControl
使用单个 构建(或某种自定义控件)ContentPresenter
吗?