I'm creating a silverlight user control that will display a transparent overlay with text over whatever xaml is contained if a property is set to true. So for example:
<my:Overlay Message="You don't have access to this feature." ShowOverlay="{Binding IsFeatureAvailable}">
<TextBox />
<Button Content="Search" />
</my:Overlay>
What I'm not quite sure about is how to implement the ability to put arbitrary xaml inside my user control, like above.
开发者_如何学JAVAThanks for any help.
Inherit your OverlayControl from ContentControl. Your template would look something like:
<Grid>
    <Grid x:Name="Overlay" Background="#30000000">
        <ContentPresenter Content="{TemplateBinding Content}"/>
    </Grid>
    <TextBlock Text="{TemplateBinding Message}"/>
</Grid>
This should work
<Grid>
<my:Overlay Message="You don't have access to this feature." ShowOverlay="{Binding IsFeatureAvailable}"/>
<TextBox />
<Button Content="Search" />
</Grid>
Also you can derrive you Overly control from ContentControl, and put content and OverLay layer in grid like shown above
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论