Skip to content

Commit

Permalink
Fixes the templates for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Jan 3, 2025
1 parent 1d92c4d commit 4323ac4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace DialogHostDemo.Models;

public class Sample2Model {
public Sample2Model(int number) {
public class Sample3Model {
public Sample3Model(int number) {
Number = number;
}
public int Number { get; set; }
Expand Down
69 changes: 39 additions & 30 deletions DialogHost.Demo/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,48 @@
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>

<Window.DataTemplates>
<DataTemplate DataType="models:Sample3Model">
<StackPanel>
<TextBlock TextAlignment="Center">Your lucky number:</TextBlock>
<TextBlock Classes="Body1"
TextAlignment="Center"
Text="{Binding Number}" />
<Button Margin="0 8 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
THANKS, CLOSE
</Button>
</StackPanel>
</DataTemplate>
</Window.DataTemplates>
<Window.Resources>
<StackPanel x:Key="Sample2View">
<TextBlock>It opened without animation</TextBlock>
<Button Margin="0 16 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
CLOSE
</Button>
</StackPanel>
<StackPanel x:Key="Sample3View">
<ProgressBar Classes="Circle" IsIndeterminate="True" />
<Button Margin="0 16 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
CLOSE
</Button>
</StackPanel>
<StackPanel x:Key="Sample4View">
<TextBlock>Everything blurred</TextBlock>
<Button Margin="0 16 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
CLOSE
</Button>
</StackPanel>
</Window.Resources>

<dialogHostAvalonia:DialogHost Identifier="MainDialogHost"
DialogMargin="16"
dialogHostAvalonia:DialogHostStyle.CornerRadius="8">
<dialogHostAvalonia:DialogHost.DataTemplates>
<DataTemplate DataType="models:Sample2Model">
<StackPanel>
<TextBlock TextAlignment="Center">Your lucky number:</TextBlock>
<TextBlock Classes="Body1"
TextAlignment="Center"
Text="{Binding Number}" />
<Button Margin="0 8 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
THANKS, CLOSE
</Button>
</StackPanel>
</DataTemplate>
</dialogHostAvalonia:DialogHost.DataTemplates>
<Grid Margin="8"
ColumnDefinitions="* 8 * 8 * 8 *" RowDefinitions="Auto 8 *"
VerticalAlignment="Center" HorizontalAlignment="Stretch">
Expand Down Expand Up @@ -94,20 +119,4 @@
</Border>
</Grid>
</dialogHostAvalonia:DialogHost>
<Window.Resources>
<StackPanel x:Key="Sample2View">
<TextBlock>It opened without animation</TextBlock>
<Button Margin="0 16 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
CLOSE
</Button>
</StackPanel>
<StackPanel x:Key="Sample3View">
<ProgressBar Classes="Circle" IsIndeterminate="True" />
<Button Margin="0 16 0 0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=dialogHostAvalonia:DialogHost}, Path=CloseDialogCommand}">
CLOSE
</Button>
</StackPanel>
</Window.Resources>
</Window>
12 changes: 6 additions & 6 deletions DialogHost.Demo/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public MainWindow() {
private void InitializeComponent() {
AvaloniaXamlLoader.Load(this);
}

private async void OpenNoAnimationDialog(object? sender, RoutedEventArgs e) {
await DialogHost.Show(Resources["Sample2View"]!, "NoAnimationDialogHost");
}

private async void OpenDialogWithView(object? sender, RoutedEventArgs e) {
await DialogHost.Show(Resources["Sample3View"]!, "MainDialogHost");
}

private async void OpenDialogWithModel(object? sender, RoutedEventArgs e) {
await DialogHost.Show(new Sample2Model(new Random().Next(0, 100)), "MainDialogHost");
}

private async void OpenNoAnimationDialog(object? sender, RoutedEventArgs e) {
await DialogHost.Show(Resources["Sample2View"]!, "NoAnimationDialogHost");
await DialogHost.Show(new Sample3Model(new Random().Next(0, 100)), "MainDialogHost");
}

private async void OpenBlurDialog(object? sender, RoutedEventArgs e) {
await DialogHost.Show(Resources["Sample2View"]!, "BlurDialogHost");
await DialogHost.Show(Resources["Sample4View"]!, "BlurDialogHost");
}
}

0 comments on commit 4323ac4

Please sign in to comment.