views:

32

answers:

0

I have a WPF Window that has a WinForms Button inside. When I set the Style of the Window the button isn't rendered, but when the Window Style is not set the Button appears as it should be.

Window Xaml:

<Window x:Class="Telbit.TeStudio.View.Forms.FloatingTestComponentsBrowser"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="Test Components Browser" Style="{DynamicResource TSHUD}"
    SizeToContent="WidthAndHeight" Closing="Window_Closing" >

    <Grid Name="windowContent" Height="300" Width="300">
            <WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <wf:Button Text="Try" Name="btnTry" MaximumSize="100,25" BackColor="LightGray"/>
            </WindowsFormsHost>
    </Grid>
</Window>

Here is the Style for the window:

<Style x:Key="TSHUD" TargetType="{x:Type Window}">
    <Setter Property="ShowInTaskbar" Value="False"/>
    <Setter Property="BorderThickness" Value="0px"/>
    <Setter Property="AllowsTransparency" Value="True"/>
    <Setter Property="WindowStyle" Value="None"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Window}">
                <Grid x:Name="LayoutRoot">
                    <Rectangle Fill="#ED111F29" Stroke="Black" Margin="29,29,29,29" RadiusX="3" RadiusY="3" Effect="{DynamicResource TSWindowShadow}"/>

                    <Rectangle Name="TSHUDHeader" Stroke="Black" Margin="29,29,29,29" VerticalAlignment="Top" Height="25" RadiusX="3" RadiusY="3">
                        <Rectangle.Fill>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#ED1F3A45"/>
                                <GradientStop Color="#EC111F29" Offset="1"/>
                            </LinearGradientBrush>
                        </Rectangle.Fill>
                    </Rectangle>

                    <Rectangle Name="TSHUDHeaderSplitter" Fill="#ED374551" Margin="30,54,30,29" VerticalAlignment="Top" Height="1"/>

                    <Label Name="TSHudTitle" Background="Transparent"
                               Margin="41,34,41,29" Padding="0"
                               HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="20" >
                        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}, AncestorLevel=1}, Path=Title}"
                                   TextWrapping="Wrap" Foreground="#FF8395B1" FontWeight="Bold"/>
                    </Label>

                    <ContentPresenter/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I have other windows with the same style but only with WPF controls (some with default style and some with custom style) and there is no problem.

I've tried to Enable Visual Styles with no luck..

Thanks in advance for any help...