Creating Silverlight Overlay User Control
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
精彩评论