我尝试在Xaml的窗口上应用样式。但我的代码并没有应用这种风格。任何人都可以帮我解决这个问题吗?
<Window x:Class="Shweta.Window5"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window5" Height="300" Width="300">
<Window.Resources>
<Style TargetType="{x:Type Window}">
<Setter Property="FontFamily" Value="Verdana"></Setter>
<Setter Property="Foreground" Value="LightBlue"></Setter>
<Setter Property="FontWeight" Value="Normal"></Setter>
<Setter Property="WindowStyle" Value="None"></Setter>
<Setter Property="Background" Value="LightBlue"></Setter>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40*" />
<ColumnDefinition Width="238*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="47*" />
<RowDefinition Height="214*" />
</Grid.RowDefinitions>
<Grid Grid.Column="1">
<Button Margin="0,0,114,16" Content="shweta"/>
</Grid>
</Grid>
</Window>
答案 0 :(得分:2)
您可以直接将其分配到窗口的Resources
属性,而不是将样式放入窗口Style
:
<Window x:Class="Shweta.Window5"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window5" Height="300" Width="300">
<Window.Style>
<Style TargetType="{x:Type Window}">
<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="Foreground" Value="LightBlue"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="Background" Value="LightBlue"/>
</Style>
</Window.Style>
...
</Window>
答案 1 :(得分:0)
您必须将自己的风格放在App.xaml的Resources
。
<Application.Resources>
<Style TargetType="{x:Type Window}">
<Setter Property="FontFamily"
Value="Verdana"></Setter>
<Setter Property="Foreground"
Value="LightBlue"></Setter>
<Setter Property="FontWeight"
Value="Normal"></Setter>
<Setter Property="WindowStyle"
Value="None"></Setter>
<Setter Property="Background"
Value="LightBlue"></Setter>
</Style>
</Application.Resources>
当您在Style
中定义Window
时,Window
代替Window
但不是dummy_array(date) - average_temperature
- average_wind_velocity
本身。