-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.cs
277 lines (245 loc) · 10.9 KB
/
MainWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.ObjectModel;
namespace ModernWinUI
{
// Main window class
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
Title = "Modern WinUI App";
}
}
// Main page XAML
/*
<Window
x:Class="ModernWinUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ModernWinUI">
<Grid>
<NavigationView x:Name="NavView"
IsSettingsVisible="True"
IsBackButtonVisible="Auto"
SelectionChanged="NavView_SelectionChanged"
BackRequested="NavView_BackRequested">
<NavigationView.MenuItems>
<NavigationViewItem Icon="Home" Content="Home" Tag="home"/>
<NavigationViewItem Icon="Document" Content="Documents" Tag="documents"/>
<NavigationViewItem Icon="People" Content="Users" Tag="users"/>
<NavigationViewItem Icon="Download" Content="Downloads" Tag="downloads"/>
</NavigationView.MenuItems>
<Frame x:Name="ContentFrame" Padding="12">
<Frame.ContentTransitions>
<TransitionCollection>
<NavigationThemeTransition/>
</TransitionCollection>
</Frame.ContentTransitions>
</Frame>
</NavigationView>
</Grid>
</Window>
*/
// Home page with modern controls
public sealed partial class HomePage : Page
{
public ObservableCollection<NewsItem> NewsItems { get; } = new ObservableCollection<NewsItem>();
public ObservableCollection<Project> Projects { get; } = new ObservableCollection<Project>();
public HomePage()
{
this.InitializeComponent();
LoadSampleData();
}
private void LoadSampleData()
{
// Sample news items
NewsItems.Add(new NewsItem { Title = "New Feature Released", Description = "Check out our latest update!", Date = DateTime.Now });
NewsItems.Add(new NewsItem { Title = "System Update", Description = "Important security patches", Date = DateTime.Now.AddDays(-1) });
// Sample projects
Projects.Add(new Project { Name = "Project Alpha", Progress = 75, Status = "In Progress" });
Projects.Add(new Project { Name = "Project Beta", Progress = 30, Status = "Planning" });
}
}
public class HomePageViewModel
{
public ObservableCollection<NewsItem> NewsItems { get; }
public ObservableCollection<Project> Projects { get; }
public HomePageViewModel()
{
NewsItems = new ObservableCollection<NewsItem>();
Projects = new ObservableCollection<Project>();
LoadData();
}
}
// Home page XAML
/*
<Page
x:Class="ModernWinUI.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<ScrollViewer>
<StackPanel Spacing="20" Padding="20">
<!-- Welcome section -->
<InfoBar Title="Welcome Back!"
Message="Here's your daily summary"
Severity="Informational"
IsOpen="True"/>
<!-- Quick actions -->
<CommandBar DefaultLabelPosition="Right">
<AppBarButton Icon="Add" Label="New Project"/>
<AppBarButton Icon="Mail" Label="Messages"/>
<AppBarButton Icon="Calendar" Label="Schedule"/>
</CommandBar>
<!-- News section -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Latest News"
Style="{StaticResource SubtitleTextBlockStyle}"
Margin="0,0,0,12"/>
<ItemsRepeater Grid.Row="1"
ItemsSource="{x:Bind NewsItems}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<InfoBar Title="{Binding Title}"
Message="{Binding Description}"
IsOpen="True"
IsCloseable="False"
Margin="0,0,0,8"/>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
<!-- Projects section -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Active Projects"
Style="{StaticResource SubtitleTextBlockStyle}"
Margin="0,0,0,12"/>
<ItemsRepeater Grid.Row="1"
ItemsSource="{x:Bind Projects}">
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,16">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}"
Style="{StaticResource BodyTextBlockStyle}"/>
<TextBlock Grid.Column="1"
Text="{Binding Status}"
Style="{StaticResource CaptionTextBlockStyle}"/>
</Grid>
<ProgressBar Value="{Binding Progress}"
Maximum="100"
Margin="0,4,0,0"/>
</StackPanel>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
<!-- Settings card -->
<ExpanderCard Header="Settings">
<StackPanel Spacing="8">
<ToggleSwitch Header="Dark Mode"/>
<ToggleSwitch Header="Notifications"/>
<Slider Header="Animation Speed"
Minimum="0"
Maximum="100"
Value="50"/>
</StackPanel>
</ExpanderCard>
</StackPanel>
</ScrollViewer>
</Grid>
</Page>
*/
// Data models
public class NewsItem
{
public string Title { get; set; }
public string Description { get; set; }
public DateTime Date { get; set; }
}
public class Project
{
public string Name { get; set; }
public int Progress { get; set; }
public string Status { get; set; }
}
// Settings page
public sealed partial class SettingsPage : Page
{
public SettingsPage()
{
this.InitializeComponent();
}
}
// Settings page XAML
/*
<Page
x:Class="ModernWinUI.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Spacing="10" Padding="20">
<SettingsExpander Header="Display">
<SettingsExpander.Items>
<SettingsExpanderItem Content="Theme">
<SettingsExpanderItem.IconSource>
<SymbolIconSource Symbol="Brightness"/>
</SettingsExpanderItem.IconSource>
<ComboBox SelectedIndex="0">
<ComboBoxItem Content="System"/>
<ComboBoxItem Content="Light"/>
<ComboBoxItem Content="Dark"/>
</ComboBox>
</SettingsExpanderItem>
<SettingsExpanderItem Content="Font Size">
<SettingsExpanderItem.IconSource>
<SymbolIconSource Symbol="FontSize"/>
</SettingsExpanderItem.IconSource>
<Slider Width="200" Value="14" Minimum="8" Maximum="24"/>
</SettingsExpanderItem>
</SettingsExpander.Items>
</SettingsExpander>
<SettingsExpander Header="Notifications">
<SettingsExpander.Items>
<SettingsExpanderItem Content="Enable Notifications">
<ToggleSwitch IsOn="True"/>
</SettingsExpanderItem>
<SettingsExpanderItem Content="Sound">
<ToggleSwitch IsOn="True"/>
</SettingsExpanderItem>
</SettingsExpander.Items>
</SettingsExpander>
<SettingsExpander Header="Privacy">
<SettingsExpander.Items>
<SettingsExpanderItem Content="Send Usage Data">
<ToggleSwitch IsOn="False"/>
</SettingsExpanderItem>
</SettingsExpander.Items>
</SettingsExpander>
<SettingsExpander Header="About">
<StackPanel Spacing="8">
<TextBlock Text="Modern WinUI App"/>
<TextBlock Text="Version 1.0.0"/>
<HyperlinkButton Content="Check for Updates"/>
</StackPanel>
</SettingsExpander>
</StackPanel>
</Page>
*/
}