The problem is that it is not installed:

I define a pattern:

<Window.Resources> <Style x:Key="ButtonTemplate" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <Border BorderBrush="#FF797979" BorderThickness="1" > <ContentPresenter HorizontalAlignment="Center"/> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <Button Style="{StaticResource ButtonTemplate}" Content="Кнопка" Name="my_button"/> 

When changing the background does not change:

 my_button.Background = Brushes.AliceBlue; 

Tell me.

    1 answer 1

    The problem was solved by binding the property to the template.

      <Grid Background="{TemplateBinding Background}"> 

    Can anyone suggest other options?

    Although, MSDN writes: "The only way to control the contents of the control pattern is to control it from the same pattern."

    • one
      This is the easiest and correct way of all. - AlexzundeR