8
我有这个XAML。如果我删除了StackPanel.Resources部分,我将获得在应用程序级别定义的样式。如果我把它放进去,那么我只能得到新的样式。WPF风格继承
如何让它结合本地和全球风格?
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" >
<StackPanel.Resources>
<Style TargetType="TextBlock" >
<Setter Property="Margin" Value="4" />
</Style>
<Style TargetType="Button" >
<Setter Property="Margin" Value="4" />
</Style>
</StackPanel.Resources>
<Border Padding="5" BorderBrush="Blue" BorderThickness="4" >
<StackPanel>
<TextBlock>Applications</TextBlock>
<Button>Open Issues</Button>
<Button>Services</Button>
</StackPanel>
</Border>
</StackPanel>
<StackPanel></StackPanel>
</DockPanel>
</Window>
如果有帮助,这是我如何定义globla样式。
<Application x:Class="Application"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="ShinyBlue.xaml"/>
</Application.Resources>
</Application>
如果应用程序级别样式没有什么名? – 2010-01-23 09:21:51
你只是给BaseTypeName像“TextBlock” – 2010-01-23 09:31:34
你的意思是像