There is an event click on the button:
void new_button_click(object sender, RoutedEventArgs e) { Button btn = sender as Button; btn.? } I want the button to rotate 90 degrees when clicked. How to implement it?
You can do with triggers:
<Button Width="100" Height="50" Content="bla-bla"> <Button.Style> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter Property="LayoutTransform"> <Setter.Value> <RotateTransform Angle="90"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> UPD Render style to window resource:
<Window.Resources> <ResourceDictionary> <Style TargetType="{x:Type Button}"> <Style.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter Property="LayoutTransform"> <Setter.Value> <RotateTransform Angle="90"/> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> </ResourceDictionary> </Window.Resources> I want one click - one turn. and I need not all buttons to turn. And certain.
Specify in the style x:Key="styleBtn" and then specify the style on the buttons you want to rotate:
<Button Style="{StaticResource styleBtn}"/> ResourceDictionary . - VladDSource: https://ru.stackoverflow.com/questions/572279/
All Articles