Skip to content

Commit

Permalink
#87 button content aligment
Browse files Browse the repository at this point in the history
  • Loading branch information
Larymar committed Dec 12, 2021
1 parent 13e4d0f commit 8d310d9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/MessageBox.Avalonia/Styles/HyperlinkStyle.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Styles
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:MessageBox.Avalonia.Controls;assembly=MessageBox.Avalonia">
<Style Selector="c|Hyperlink">
<Setter Property="Foreground" Value="#3483eb" />
</Style>
<Style Selector="c|Hyperlink:pointerover">
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="TextDecorations" Value="Underline"/>
<Setter Property="Foreground" Value="#3496eb"/>
</Style>
</Styles>
3 changes: 2 additions & 1 deletion src/MessageBox.Avalonia/Views/MsBoxCustomWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
Text="{Binding ContentMessage}" />
</Grid>
<!--Buttons-->
<ItemsPresenter Classes="buttons-item-presenter" Items="{Binding ButtonDefinitions}" Grid.Row="3"
<ItemsPresenter Name="ButtonItemsPresenter" Classes="buttons-item-presenter" Items="{Binding ButtonDefinitions}" Grid.Row="3"
Grid.Column="1" Grid.ColumnSpan="3"
HorizontalAlignment="Right">
<ItemsPresenter.ItemsPanel>
Expand All @@ -88,6 +88,7 @@
<ItemsPresenter.ItemTemplate>
<DataTemplate>
<Button Name="Btn"
HorizontalContentAlignment="Center"
Classes.buttons = "true"
Classes.default = "{Binding IsDefault}"
Classes.cancel = "{Binding IsCancel}"
Expand Down
19 changes: 13 additions & 6 deletions src/MessageBox.Avalonia/Views/MsBoxStandardWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
<Style Selector="Button">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Margin" Value="15 0 0 0" />
<Setter Property="MinHeight" Value="24" />
<Setter Property="MinWidth" Value="75" />
Expand Down Expand Up @@ -85,22 +86,28 @@
<TextBox Grid.Row="0" Classes="header" FontFamily="{Binding FontFamily}" Text="{Binding ContentHeader}"
IsVisible="{Binding HasHeader}" />
<!--Content text-->
<TextBox Grid.Row="1" Classes="contentMessage" FontFamily="{Binding FontFamily}" Text="{Binding ContentMessage}" />
<TextBox Grid.Row="1" Classes="contentMessage" FontFamily="{Binding FontFamily}"
Text="{Binding ContentMessage}" />

</Grid>
<!--Buttons-->
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
HorizontalAlignment="Right">
<Button Classes="button ok" Name="OkButton" Content="OK" Tag="Colored" Command="{Binding ButtonClickCommand}"
<Button Classes="button ok" Name="OkButton" Content="OK" Tag="Colored"
Command="{Binding ButtonClickCommand}"
CommandParameter="{Binding $self.Content}"
IsVisible="{Binding IsOkShowed}" />
<Button Classes="button yes" Name="YesButton" Content="Yes" Command="{Binding ButtonClickCommand}" CommandParameter="{Binding $self.Content}"
<Button Classes="button yes" Name="YesButton" Content="Yes" Command="{Binding ButtonClickCommand}"
CommandParameter="{Binding $self.Content}"
IsVisible="{Binding IsYesShowed}" />
<Button Classes="button no" Content="No" Command="{Binding ButtonClickCommand}" CommandParameter="{Binding $self.Content}"
<Button Classes="button no" Content="No" Command="{Binding ButtonClickCommand}"
CommandParameter="{Binding $self.Content}"
IsVisible="{Binding IsNoShowed}" />
<Button Classes="button abort" Content="Abort" Command="{Binding ButtonClickCommand}" CommandParameter="{Binding $self.Content}"
<Button Classes="button abort" Content="Abort" Command="{Binding ButtonClickCommand}"
CommandParameter="{Binding $self.Content}"
IsVisible="{Binding IsAbortShowed}" />
<Button Classes="button cancel" Content="Cancel" Command="{Binding ButtonClickCommand}" CommandParameter="{Binding $self.Content}"
<Button Classes="button cancel" Content="Cancel" Command="{Binding ButtonClickCommand}"
CommandParameter="{Binding $self.Content}"
IsVisible="{Binding IsCancelShowed}" />
</StackPanel>
</Grid>
Expand Down
8 changes: 8 additions & 0 deletions src/MessageBox.Avalonia/Views/MsBoxStandardWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using MessageBox.Avalonia.BaseWindows.Base;
Expand All @@ -17,6 +18,13 @@ public MsBoxStandardWindow() : base()

public ButtonResult GetResult() => ButtonResult;

/// <inheritdoc />
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
var okButton = this.FindControl<Button>("OkButton");
okButton.Focus();
}

private void InitializeComponent()
{
Expand Down

0 comments on commit 8d310d9

Please sign in to comment.