Simplify QuestionControl.axaml
MODIFY
WalletWasabi.Fluent/Controls/QuestionControl.axaml
WalletWasabi.Fluent/Controls/QuestionControl.axaml
<ControlTemplate>
<DockPanel VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
- <DockPanel HorizontalAlignment="Stretch" MaxWidth="500" DockPanel.Dock="Bottom">
- <Button Name="PART_NoButton" HorizontalAlignment="Left" Content="No" Classes="yesNo"
+ <DockPanel
+ x:DataType="c:QuestionControl"
+ x:CompileBindings="True"
+ Classes="h6"
+ HorizontalAlignment="Stretch" MaxWidth="500" DockPanel.Dock="Bottom">
+ <Button Name="PART_NoButton"
+ HorizontalAlignment="Left"
+ Content="No"
+ Classes.action="{TemplateBinding IsYesButton}"
+ Classes="yesNo"
Command="{TemplateBinding NoCommand}" />
- <Button Name="PART_YesButton" HorizontalAlignment="Right" Content="Yes" Classes="yesNo"
+ <Button Name="PART_YesButton"
+ HorizontalAlignment="Right"
+ Content="Yes"
+ Classes.action="{TemplateBinding IsNoButton}"
+ Classes="yesNo"
Command="{TemplateBinding YesCommand}" />
</DockPanel>
<ContentPresenter Content="{TemplateBinding Content}"
</Setter>
</Style>
- <Style Selector="c|QuestionControl">
- <Setter Property="FontSize" Value="{StaticResource FontSizeH6}" />
- </Style>
-
<!-- YesNo Button style -->
<Style Selector="Button.yesNo">
<Setter Property="Width" Value="150" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
- <Setter Property="FontSize" Value="{StaticResource FontSizeH6}" />
<Setter Property="Padding" Value="0" />
</Style>
-
- <!-- YesNo Button background -->
- <Style
- Selector="c|QuestionControl[HighlightButton=NoButton] /template/ Button#PART_NoButton,
- c|QuestionControl[HighlightButton=YesButton] /template/ Button#PART_YesButton,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_NoButton,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_YesButton">
- <Setter Property="Background" Value="{DynamicResource ActionButtonBackgroundColor}" />
- </Style>
-
- <!-- YesNo Button pointerover -->
- <Style
- Selector="c|QuestionControl[HighlightButton=YesButton] /template/ Button#PART_YesButton.yesNo:pointerover /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=NoButton] /template/ Button#PART_NoButton.yesNo:pointerover /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_NoButton.yesNo:pointerover /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_YesButton.yesNo:pointerover /template/ ContentPresenter">
- <Setter Property="Background" Value="{DynamicResource ActionButtonPointerOverBackgroundColor}" />
- </Style>
-
- <!-- YesNo Button pressed -->
- <Style
- Selector="c|QuestionControl[HighlightButton=YesButton] /template/ Button#PART_YesButton.yesNo:pressed /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=NoButton] /template/ Button#PART_NoButton.yesNo:pressed /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_NoButton.yesNo:pressed /template/ ContentPresenter,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_YesButton.yesNo:pressed /template/ ContentPresenter">
- <Setter Property="Background" Value="{DynamicResource ActionButtonPressedBackgroundColor}" />
- </Style>
-
- <!-- IsDefault -->
- <Style Selector="c|QuestionControl[HighlightButton=Both] /template/ Button#PART_NoButton,
- c|QuestionControl[HighlightButton=Both] /template/ Button#PART_YesButton">
- <Setter Property="IsDefault" Value="false" />
- </Style>
- <Style Selector="c|QuestionControl[HighlightButton=NoButton] /template/ Button#PART_NoButton">
- <Setter Property="IsDefault" Value="{Binding IsActive}" />
- </Style>
- <Style Selector="c|QuestionControl[HighlightButton=YesButton] /template/ Button#PART_YesButton">
- <Setter Property="IsDefault" Value="{Binding IsActive}" />
- </Style>
</Styles>
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Controls/QuestionControl.axaml.cs
WalletWasabi.Fluent/Controls/QuestionControl.axaml.cs
@@ -29,6 +29,12 @@ public class QuestionControl : ContentControl
public static readonly StyledProperty<HighlightedButton> HighlightButtonProperty =
AvaloniaProperty.Register<QuestionControl, HighlightedButton>(nameof(HighlightButton));
+ public static readonly StyledProperty<bool> IsYesButtonProperty =
+ AvaloniaProperty.Register<QuestionControl, bool>(nameof(IsYesButton));
+
+ public static readonly StyledProperty<bool> IsNoButtonProperty =
+ AvaloniaProperty.Register<QuestionControl, bool>(nameof(IsNoButton));
+
public ICommand YesCommand
{
get => GetValue(YesCommandProperty);
@@ -47,6 +53,18 @@ public class QuestionControl : ContentControl
set => SetValue(ImageIconProperty, value);
}
+ public bool IsYesButton
+ {
+ get => GetValue(IsYesButtonProperty);
+ set => SetValue(IsYesButtonProperty, value);
+ }
+
+ public bool IsNoButton
+ {
+ get => GetValue(IsNoButtonProperty);
+ set => SetValue(IsNoButtonProperty, value);
+ }
+
public object? IconContent
{
get => GetValue(IconContentProperty);
@@ -61,7 +79,7 @@ public class QuestionControl : ContentControl
public QuestionControl()
{
- UpdatePseudoClasses(HighlightButton);
+ UpdateHighlightedButton(HighlightButton);
}
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change)
@@ -70,13 +88,13 @@ public class QuestionControl : ContentControl
if (change.Property == HighlightButtonProperty)
{
- UpdatePseudoClasses(change.NewValue.GetValueOrDefault<HighlightedButton>());
+ UpdateHighlightedButton(change.NewValue.GetValueOrDefault<HighlightedButton>());
}
}
- private void UpdatePseudoClasses(HighlightedButton highlightedButton)
+ private void UpdateHighlightedButton(HighlightedButton highlightedButton)
{
- PseudoClasses.Set(":yes", highlightedButton == HighlightedButton.YesButton);
- PseudoClasses.Set(":no", highlightedButton == HighlightedButton.NoButton);
+ IsYesButton = highlightedButton == HighlightedButton.YesButton;
+ IsNoButton = highlightedButton == HighlightedButton.NoButton;
}
}

Simplify QuestionControl.axaml