進出口新的WPF我想用一種風格和className.property廣東話設置樣式使用className.property
風格並不適用於第一個文本框
事實上的母校它適用於堆疊面板
我錯過了什麼嗎?
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="883">
<Grid>
<Grid.Resources >
<Style x:Key="m">
<Setter Property="TextBox.Background" Value="Aqua"/>
</Style>
</Grid.Resources>
<TextBlock >adsdfsadfasdfad</TextBlock>
<StackPanel Orientation="Horizontal" Style="{StaticResource m}">
<TextBox HorizontalAlignment="Stretch" Width="193" Margin="50">
</TextBox>
<TextBox HorizontalAlignment="Stretch" Width="193" Background="Black" Margin="50">
</TextBox>
</StackPanel>
</Grid>
看看this文章 找到屬性= 「ClassName.Property」 在 謝謝。
ClassName.Propert與您在樣式中設置的屬性相關,而不是與樣式目標控件相關 –