我有一个内置WinForms按钮的WPF窗口。当我设置窗口的样式时,按钮不会被渲染,但是当没有设置窗口样式时,按钮就会出现,应该是。
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>
这是窗口的样式:
<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>
我有其他窗口具有相同的样式,但只有WPF控件(一些具有默认样式,一些具有自定义样式)并且没有问题。
我试过Enable Visual Styles没有运气..
提前感谢您的帮助......