There is a UserControl , it has Width , Height and Backgroung .
When using this control, it is impossible to override these values through the style, why?
User Control:
<UserControl x:Class="ExperimentsWpf.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Width="100" Height="100" d:DesignHeight="450" d:DesignWidth="800" Background="Red" mc:Ignorable="d" /> Using:
<Window x:Class="ExperimentsWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ExperimentsWpf"> <Window.Resources> <Style x:Key="StyleUserControl1" TargetType="{x:Type local:UserControl1}"> <Setter Property="Width" Value="10" /> <Setter Property="Height" Value="10" /> <Setter Property="Background" Value="Green" /> </Style> </Window.Resources> <Grid VerticalAlignment="Center"> <local:UserControl1 Style="{StaticResource StyleUserControl1}" /> </Grid> </Window>