I can not apply the Style for custom UserControl. Styles for TextBlock and MyControl are in the same dictionary. Style for TextBlock used without problems. But for MyControl style is not applied. Why?
// XAML xmlns:local="clr-namespace:MyControlNameSpace" <Grid> <TextBlock x:Name="text" Style="{DynamicResource TextStyle}"/> <local:MyControl x:Name="control" Style="{DynamicResource ControlStyle}"/> </Grid> // RESOURCE DICTIONARY <Style x:Key="ControlStyle" TargetType="{x:Type local:MyControl}"> <Setter Property="Height" Value="Auto"/> <Setter Property="Width" Value="Auto"/> <Setter Property="Foreground" Value="White"/> <Setter Property="ColorMain" Value="Black"/> <Setter Property="Margin" Value="2"/> </Style> <Style x:Key="TextStyle" TargetType="{x:Type TextBlock}"> .... <Setter Property="FontSize" Value="32"/> ... </Style>
//PART of CS
public partial class MyControl: UserControl { .... }