开发者

Creating Silverlight Overlay User Control

开发者 https://www.devze.com 2023-02-13 06:59 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消