Головна‎ > ‎C# WPF‎ > ‎

Кнопка (Button)

<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="50" Height="50" HorizontalContentAlignment="Left" Margin="50,0,0,0" />


Зміна позиції іншого об'єкту (код)

label.Margin = new Thickness(label.Margin.Left+10, label.Margin.Top, 0, 0);



Зміна кольру при наведенні

<Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="50" Height="50" HorizontalContentAlignment="Left" BorderBrush="{x:Null}" Foreground="{x:Null}" Margin="50,0,0,0">
   <Button.Style>
      <Style TargetType="{x:Type Button}">
         <Setter Property="Background" Value="Green"/>
         <Setter Property="Template">
            <Setter.Value>
                 <ControlTemplate TargetType="{x:Type Button}">
                   <Border Background="{TemplateBinding Background}">
                     <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                   </Border>
                </ControlTemplate>
              </Setter.Value>
           </Setter>
           <Style.Triggers>
              <Trigger Property="IsMouseOver" Value="True">
                 <Setter Property="Background" Value="Blue"/>
              </Trigger>
          </Style.Triggers>
      </Style>
   </Button.Style>
</Button>