Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/MainDemo.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaterialDesign.Shared;
using System.Reflection;
using MaterialDesign.Shared;
using MaterialDesignThemes.Wpf;
using ShowMeTheXAML;

Expand Down Expand Up @@ -32,7 +33,9 @@ protected override void OnStartup(StartupEventArgs e)
XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
*/

XamlDisplay.Init();
var sharedAssembly
= Assembly.GetAssembly(typeof(MaterialDesignDemo.Shared.IMaterialDesignDemoSharedAssemblyMarker));
XamlDisplay.Init(sharedAssembly);

// test setup for Persian culture settings
/*System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fa-Ir");
Expand Down
12 changes: 12 additions & 0 deletions src/MainDemo.Wpf/Dialogs.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
xmlns:shared="clr-namespace:MaterialDesignDemo.Shared.Examples.Dialogs;assembly=MaterialDesignDemo.Shared"
xmlns:system="clr-namespace:System;assembly=mscorlib"
d:DataContext="{d:DesignInstance domain:DialogsViewModel}"
d:DesignHeight="1080"
Expand Down Expand Up @@ -368,5 +369,16 @@
</materialDesign:DialogHost>
</smtx:XamlDisplay>
<!--#endregion-->

<Rectangle Style="{StaticResource PageSectionSeparator}" />

<!--#region SAMPLE 7 - WaitForOpened / WaitForClosed demo-->
<TextBlock Style="{StaticResource PageSectionTitleTextBlock}" Text="Sample 7 - WaitForOpened / WaitForClosed" />

<TextBlock Margin="0,0,0,8"
Text="The DialogHost.WaitForOpened() and DialogHost.WaitForClosed() methods can be used to wait until the dialog is fully opened or closed respectively."
TextWrapping="Wrap" />
<shared:DialogHostWaitForExample />
<!--#endregion-->
</StackPanel>
</UserControl>
10 changes: 10 additions & 0 deletions src/MaterialDesign3.Demo.Wpf/Dialogs.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:domain="clr-namespace:MaterialDesign3Demo.Domain"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shared="clr-namespace:MaterialDesignDemo.Shared.Examples.Dialogs;assembly=MaterialDesignDemo.Shared"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
xmlns:system="clr-namespace:System;assembly=mscorlib"
d:DataContext="{d:DesignInstance domain:DialogsViewModel}"
Expand Down Expand Up @@ -46,6 +47,7 @@
<ColumnDefinition Width="320" />
<ColumnDefinition Width="320" />
<ColumnDefinition Width="320" />
<ColumnDefinition Width="600" />
</Grid.ColumnDefinitions>

<!--#region SAMPLE 1-->
Expand Down Expand Up @@ -325,6 +327,14 @@
</materialDesign:DialogHost>
</smtx:XamlDisplay>
<!--#endregion-->

<!--#region SAMPLE 6 - WaitForOpened / WaitForClosed demo-->
<StackPanel Grid.Row="0" Grid.Column="5">
<TextBlock Text="SAMPLE 6: WaitForOpened / WaitForClosed" />
<TextBlock Text="The DialogHost.WaitForOpened() and DialogHost.WaitForClosed() methods can be used to wait until the dialog is fully opened or closed respectively." TextWrapping="Wrap" />
</StackPanel>
<shared:DialogHostWaitForExample Grid.Row="1" Grid.Column="5" />
<!--#endregion-->
</Grid>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<UserControl x:Class="MaterialDesignDemo.Shared.Examples.Dialogs.DialogHostWaitForExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:smtx="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<smtx:XamlDisplay UniqueKey="DialogHostWaitForExample">
<Border MinHeight="160"
Padding="16"
BorderBrush="{DynamicResource PrimaryHueMidBrush}"
BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="280" />
</Grid.ColumnDefinitions>

<materialDesign:DialogHost x:Name="SampleDialogHost" Grid.Column="0">
<materialDesign:DialogHost.DialogContent>
<StackPanel Margin="16">
<TextBlock Margin="0,0,0,8" Text="This is sample dialog content." />
<Button Click="Sample_CloseButton_Click"
Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}"
Content="Close Dialog"
Style="{StaticResource MaterialDesignFlatButton}" />
</StackPanel>
</materialDesign:DialogHost.DialogContent>
<Button HorizontalAlignment="Center"
Click="Sample_OpenButton_Click"
Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
Content="Open Dialog"
Style="{StaticResource MaterialDesignRaisedButton}" />
</materialDesign:DialogHost>

<StackPanel Grid.Column="1">
<materialDesign:Card Padding="8"
VerticalAlignment="Top"
UniformCornerRadius="8">
<StackPanel>
<WrapPanel>
<TextBlock Text="Open button clicked: " />
<TextBlock x:Name="Sample_OpenClicked" />
</WrapPanel>

<materialDesign:Chip HorizontalAlignment="Right" Foreground="Green">
<WrapPanel VerticalAlignment="Center">
<materialDesign:PackIcon Kind="ArrowLeftBottom" RenderTransformOrigin="0.5 0.5">
<materialDesign:PackIcon.RenderTransform>
<RotateTransform Angle="-45" />
</materialDesign:PackIcon.RenderTransform>
</materialDesign:PackIcon>
<TextBlock x:Name="Sample_OpenTimeDifference" />
</WrapPanel>
</materialDesign:Chip>

<WrapPanel>
<TextBlock Text="Opened animation finished: " />
<TextBlock x:Name="Sample_OpenedFinished" />
</WrapPanel>
</StackPanel>
</materialDesign:Card>

<materialDesign:Card Margin="0,8,0,0"
Padding="8"
VerticalAlignment="Top"
UniformCornerRadius="8">
<StackPanel>
<WrapPanel>
<TextBlock Text="Closed button clicked: " />
<TextBlock x:Name="Sample_CloseClicked" />
</WrapPanel>

<materialDesign:Chip HorizontalAlignment="Right" Foreground="{DynamicResource MaterialDesign.Brush.ValidationError}">
<WrapPanel VerticalAlignment="Center">
<materialDesign:PackIcon Kind="ArrowLeftBottom" RenderTransformOrigin="0.5 0.5">
<materialDesign:PackIcon.RenderTransform>
<RotateTransform Angle="-45" />
</materialDesign:PackIcon.RenderTransform>
</materialDesign:PackIcon>
<TextBlock x:Name="Sample_CloseTimeDifference" />
</WrapPanel>
</materialDesign:Chip>

<WrapPanel>
<TextBlock Text="Closed animation finished: " />
<TextBlock x:Name="Sample_ClosedFinished" />
</WrapPanel>
</StackPanel>
</materialDesign:Card>
</StackPanel>
</Grid>
</Border>
</smtx:XamlDisplay>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using ShowMeTheXAML;

namespace MaterialDesignDemo.Shared.Examples.Dialogs;

/// <summary>
/// Interaction logic for DialogHostWaitForExample.xaml
/// </summary>
public partial class DialogHostWaitForExample : UserControl
{
private DateTime? _sampleOpenClicked;
private DateTime? _sampleCloseClicked;

public DialogHostWaitForExample()
{
InitializeComponent();
}

private async void Sample_OpenButton_Click(object sender, RoutedEventArgs e)
{
_sampleOpenClicked = DateTime.Now;
Sample_OpenClicked.Text = _sampleOpenClicked.Value.TimeOfDay.ToString(@"hh\:mm\:ss\.fff");

await SampleDialogHost.WaitForOpened();
var openedFinished = DateTime.Now;
Sample_OpenedFinished.Text = openedFinished.TimeOfDay.ToString(@"hh\:mm\:ss\.fff");

if (_sampleOpenClicked.HasValue)
{
var diff = openedFinished - _sampleOpenClicked.Value;
Sample_OpenTimeDifference.Text = ((long)diff.TotalMilliseconds).ToString() + " ms";
}

await SampleDialogHost.WaitForClosed();
var closedFinished = DateTime.Now;
Sample_ClosedFinished.Text = closedFinished.TimeOfDay.ToString(@"hh\:mm\:ss\.fff");

if (_sampleCloseClicked.HasValue)
{
var closeDiff = closedFinished - _sampleCloseClicked.Value;
Sample_CloseTimeDifference.Text = ((long)closeDiff.TotalMilliseconds).ToString() + " ms";
}
}

private void Sample_CloseButton_Click(object sender, RoutedEventArgs e)
{
_sampleCloseClicked = DateTime.Now;
Sample_CloseClicked.Text = _sampleCloseClicked.Value.TimeOfDay.ToString(@"hh\:mm\:ss\.fff");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace MaterialDesignDemo.Shared;

public interface IMaterialDesignDemoSharedAssemblyMarker;
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net8.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<ImplicitUsings>enable</ImplicitUsings>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" />
<PackageReference Include="ShowMeTheXAML" />
<PackageReference Include="ShowMeTheXAML.MSBuild" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading