tags:

views:

125

answers:

1

I want to change my window template, eg:

<Style x:Key="SilverGreenWindowStyle" TargetType="{x:Type Window}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Grid Background="{StaticResource SilverGreenBackground}" Width="503" Height="383">
                    <Rectangle Margin="192,86,21,119" Fill="{StaticResource SilverGreenRectangleBackground}" Width="200" Height="200"/>
                </Grid>    
            </ControlTemplate>
        </Setter.Value>    
    </Setter>
</Style>

and that causes the windows controls to become invisible. How do I keep them visible?

+5  A: 

You need to include an element in your template to tell the Window where to display it's content. ContentPresenter does the magic for you: it will render the Window's content at whatever position you insert it in the tree.

If you want the regular content to display on top of the Rectangle, for example, you can do this:

<Style x:Key="SilverGreenWindowStyle" TargetType="{x:Type Window}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Grid Background="{StaticResource SilverGreenBackground}" Width="503" Height="383">
                    <Rectangle Margin="192,86,21,119" Fill="{StaticResource SilverGreenRectangleBackground}" Width="200" Height="200"/>
                    <ContentPresenter/>
                </Grid>    
            </ControlTemplate>
        </Setter.Value>    
    </Setter>
</Style>
Samuel Jack