Skip to content

Commit

Permalink
Example code for SystemBackdropsPage
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Jan 3, 2025
1 parent 14eb769 commit d38c7ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel>
<local:ControlExample CSharpSource="SystemBackdrops/SystemBackdropsSample1.txt" HeaderText="Create a window with a Mica system backdrop.">
<local:ControlExample x:Name="Example1" HeaderText="Create a window with a Mica system backdrop.">
<Button Click="createMicaWindow_Click">Create Window with Mica</Button>
</local:ControlExample>

<local:ControlExample CSharpSource="SystemBackdrops/SystemBackdropsSample2.txt" HeaderText="Create a window with a Desktop Acrylic system backdrop.">
<local:ControlExample x:Name="Example2" HeaderText="Create a window with a Desktop Acrylic system backdrop.">
<Button Click="createAcrylicWindow_Click">Create Window with Acrylic</Button>
</local:ControlExample>

<local:ControlExample CSharpSource="SystemBackdrops/SystemBackdropsEnsureSystemDQC.txt" HeaderText="Helper class to ensure a Windows.System.DispatcherQueue exists.">
<TextBlock Text="A Windows.System.DispatcherQueue must exist on the thread to use MicaController or DesktopAcrylicController. This helper class exposes and uses the underlying create function." TextWrapping="Wrap" />
</local:ControlExample>
</StackPanel>
</ui:Page>
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ public partial class SystemBackdropsPage : Page
public SystemBackdropsPage()
{
InitializeComponent();
UpdateExampleCode();
}

private void createMicaWindow_Click(object sender, RoutedEventArgs e)
{
var newWindow = new SampleSystemBackdropsWindow();
WindowHelper.SetSystemBackdropType(newWindow, BackdropType.Mica);
newWindow.Show();
}

Expand All @@ -46,9 +48,24 @@ private void createAcrylicWindow_Click(object sender, RoutedEventArgs e)

public void UpdateExampleCode()
{
if (!this.IsInitialized) return;

Example1.CSharp = Example1CS;
Example2.CSharp = Example2CS;
}

public string Example1CS => $@"
var newWindow = new SampleSystemBackdropsWindow();
WindowHelper.SetSystemBackdropType(newWindow, BackdropType.Mica);
newWindow.Show();
";

public string Example2CS => $@"
var newWindow = new SampleSystemBackdropsWindow();
WindowHelper.SetSystemBackdropType(newWindow,BackdropType.Acrylic);
newWindow.Show();
";

#endregion

}
Expand Down

0 comments on commit d38c7ca

Please sign in to comment.