2011-02-25 57 views
1

我正在创建一个silverlight用户控件,该控件将显示透明覆盖图,其中包含任何包含xaml的文本,如果属性设置为true。例如:创建Silverlight覆盖用户控件

<my:Overlay Message="You don't have access to this feature." ShowOverlay="{Binding IsFeatureAvailable}"> 

<TextBox /> 
<Button Content="Search" /> 

</my:Overlay> 

我不太确定的是如何实现将任意xaml放入我的用户控件中的能力,如上所述。

感谢您的任何帮助。

回答

3

OverlayControlContentControl继承。你的模板看起来像这样:

<Grid> 
    <Grid x:Name="Overlay" Background="#30000000"> 
     <ContentPresenter Content="{TemplateBinding Content}"/> 
    </Grid> 
    <TextBlock Text="{TemplateBinding Message}"/> 
</Grid> 
1

这应该工作

<Grid> 
<my:Overlay Message="You don't have access to this feature." ShowOverlay="{Binding IsFeatureAvailable}"/> 

<TextBox /> 
<Button Content="Search" /> 

</Grid> 

您也可以derrive你过于自ContentControl控制,并把内容和覆盖层网格像上面显示