8
Bu XAML'im var. StackPanel.Resources bölümünü kaldırırsam, uygulama düzeyinde tanımlanmış stilleri alırım. Eğer onu terk edersem, o zaman yeni stilleri alırım.WPF Stil Kalıtım
Hem yerel hem de global stilleri nasıl birleştirebilirim?
<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>
Bu, yardımcı olması durumunda, globla stillerini böyle tanımladım. Bu size uygulama seviyesinden stilini de yerel seviyede verecektir
<Style TargetType="TextBlock" BasedOn="{StaticResource StyleA}" >
<Setter Property="Margin" Value="4" />
</Style>
yerel kaynak tanımı
<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>
uygulama düzeyinde stilinin bir adı yoksa ne ? –
sadece "TextBlock" –
gibi BaseTypeName verin.