Skip to content

Instantly share code, notes, and snippets.

@namhnz
Created November 18, 2021 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namhnz/3ffa1c2a02169c900753da497e3a17cc to your computer and use it in GitHub Desktop.
Save namhnz/3ffa1c2a02169c900753da497e3a17cc to your computer and use it in GitHub Desktop.
Style của button có thể thay đổi khi binding thay đổi
<ui:SimpleStackPanel Orientation="Horizontal"
Spacing="5">
<!-- https://stackoverflow.com/questions/15576589/how-to-extend-instead-of-overriding-wpf-styles/15576781 -->
<ui:SimpleStackPanel.Resources>
<Style x:Key="BatDauCaiDatButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Content" Value="Bắt đầu cài đặt"></Setter>
<Setter Property="IsEnabled" Value="True"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsInstallationInProgress}" Value="True">
<Setter Property="IsEnabled" Value="False"></Setter>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<ui:SimpleStackPanel Orientation="Horizontal"
Spacing="5">
<ui:ProgressRing IsActive="True"></ui:ProgressRing>
<TextBlock Text="Đang cài đặt..."></TextBlock>
</ui:SimpleStackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ui:SimpleStackPanel.Resources>
<Button Command="{Binding BatDauCaiDatUngDungCommand}"
Style="{StaticResource BatDauCaiDatButtonStyle}">
</Button>
<Button Content="Sao lưu cài đặt đến..." />
</ui:SimpleStackPanel>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment