我正在创建一个 silverlight 用户控件,如果属性设置为 true,它将在包含的任何 xaml 上显示带有文本的透明覆盖层。例如:
<my:Overlay Message="You don't have access to this feature." ShowOverlay="{Binding IsFeatureAvailable}">
<TextBox />
<Button Content="Search" />
</my:Overlay>
我不太确定的是如何实现将任意 xaml 放入我的用户控件中的能力,如上所示。
感谢您的帮助。
请您参考如下方法:
从 ContentControl 继承您的 OverlayControl。您的模板看起来像:
<Grid>
<Grid x:Name="Overlay" Background="#30000000">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Grid>
<TextBlock Text="{TemplateBinding Message}"/>
</Grid>
