c#wpf写的style样式两个button没实现
两个button都没什么反映,请大侠教我,style根本没什么作用啊<Windowx:Class="test3.Window1"xmlns="http://schemas...
两个button都没什么反映,请大侠教我,style根本没什么作用啊
<Window x:Class="test3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="hello" >
<Setter Property="Button.Foreground" Value="Blue"/>
<Setter Property="Button.FontFamily " Value="CourierNew"/>
<Setter Property="Button.Width" Value="20"/>
<Setter Property="Button.Height" Value="20"/>
</Style>
</Window.Resources>
<Grid ShowGridLines="True">
<Grid.Style>
<DynamicResource ResourceKey="hello"/>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25*"/>
<RowDefinition Height="25*"/>
<RowDefinition Height="25*"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" >button1</Button>
<Button Grid.Column="2" Grid.ColumnSpan="1" Grid.Row="1" >button2</Button>
</Grid>
</Window> 展开
<Window x:Class="test3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="hello" >
<Setter Property="Button.Foreground" Value="Blue"/>
<Setter Property="Button.FontFamily " Value="CourierNew"/>
<Setter Property="Button.Width" Value="20"/>
<Setter Property="Button.Height" Value="20"/>
</Style>
</Window.Resources>
<Grid ShowGridLines="True">
<Grid.Style>
<DynamicResource ResourceKey="hello"/>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*"/>
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25*"/>
<RowDefinition Height="25*"/>
<RowDefinition Height="25*"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" >button1</Button>
<Button Grid.Column="2" Grid.ColumnSpan="1" Grid.Row="1" >button2</Button>
</Grid>
</Window> 展开
展开全部
<Window.Resources>
<Style TargetType="Button" >
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontFamily" Value="宋体"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Height" Value="20"/>
</Style>
</Window.Resources>
<Grid ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0" >button1</Button>
<Button Grid.Column="2" Grid.Row="1" >button2</Button>
</Grid>
追问
我的程序主要问题在哪里,请大侠详解,我感觉我只是给style起了个名字而已,其他的和你的的一样,为什么没效果,这是我提问的关键
追答
差别大了,仔细比较!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询