File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
UI/WindowingSamples/WindowingSamples Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <Window
3
+ x : Class =" WindowingSamples.CustomWindow"
4
+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5
+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
6
+ xmlns : controls =" using:WindowingSamples.Controls"
7
+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
8
+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
9
+ mc : Ignorable =" d" >
10
+
11
+ <Grid x : Name =" RootGrid" >
12
+ <Grid .RowDefinitions>
13
+ <RowDefinition Height =" Auto" />
14
+ <RowDefinition Height =" *" />
15
+ </Grid .RowDefinitions>
16
+ <controls : WindowTitleControl Text =" Custom window" Glyph ="  " />
17
+
18
+
19
+ <StackPanel HorizontalAlignment =" Center" VerticalAlignment =" Center" Grid.Row=" 1" Spacing =" 8" >
20
+ <TextBlock x : Name =" WindowText" HorizontalAlignment =" Center" Text =" This is custom window" FontSize =" 40" />
21
+ <Button HorizontalAlignment =" Center" Click =" CloseClick" >Close</Button >
22
+ </StackPanel >
23
+ </Grid >
24
+ </Window >
Original file line number Diff line number Diff line change
1
+ using Microsoft . UI . Windowing ;
2
+ using Windows . UI ;
3
+
4
+ namespace WindowingSamples ;
5
+
6
+ /// <summary>
7
+ /// An empty window that can be used on its own or navigated to within a Frame.
8
+ /// </summary>
9
+ public sealed partial class CustomWindow : Window
10
+ {
11
+ private static int _customWindowCounter = 0 ;
12
+
13
+ public CustomWindow ( )
14
+ {
15
+ InitializeComponent ( ) ;
16
+
17
+ var random = Random . Shared ;
18
+ RootGrid . Background = new SolidColorBrush (
19
+ Color . FromArgb (
20
+ 255 ,
21
+ ( byte ) random . Next ( 0 , 150 ) ,
22
+ ( byte ) random . Next ( 0 , 150 ) ,
23
+ ( byte ) random . Next ( 0 , 150 ) ) ) ;
24
+
25
+ var text = $ "Custom Window { ++ _customWindowCounter } ";
26
+ Title = text ;
27
+ WindowText . Text = text ;
28
+ }
29
+
30
+ public void CloseClick ( object sender , RoutedEventArgs args ) => Close ( ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments