Skip to content

Commit

Permalink
Merge pull request microsoft#544 from harshit7962/addAboutpage
Browse files Browse the repository at this point in the history
Adding About Page
  • Loading branch information
dipeshmsft authored Apr 29, 2024
2 parents 35f3b39 + bfc3b98 commit 9881800
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Sample Applications/Win11ThemeGallery/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public partial class App : Application

services.AddSingleton<SettingsPage>();
services.AddSingleton<SettingsPageViewModel>();

services.AddSingleton<AboutPage>();
services.AddSingleton<AboutPageViewModel>();
}).Build();


Expand Down
49 changes: 31 additions & 18 deletions Sample Applications/Win11ThemeGallery/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,39 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBox x:Name="SearchBox"
Margin="10" Width="250"
KeyUp="SearchBox_KeyUp"
LostFocus="SearchBox_LostFocus" />
<TextBox x:Name="SearchBox"
Margin="10" Width="250"
KeyUp="SearchBox_KeyUp"
LostFocus="SearchBox_LostFocus" />


<TreeView x:Name="ControlsList"
ItemsSource="{Binding ViewModel.Controls}"
SelectedItemChanged="ControlsList_SelectedItemChanged"
Margin="10" Grid.Row="1"
>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}" >
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock FontFamily="Segoe Fluent Icons" Text="{Binding Icon}" VerticalAlignment="Center" FontSize="14" Margin="2,4,7,2"/>
<TextBlock Text="{Binding Name}" Margin="2" VerticalAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<TreeView x:Name="ControlsList"
ItemsSource="{Binding ViewModel.Controls}"
SelectedItemChanged="ControlsList_SelectedItemChanged"
Margin="10" Grid.Row="1"
>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}" >
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock FontFamily="Segoe Fluent Icons" Text="{Binding Icon}" VerticalAlignment="Center" FontSize="14" Margin="2,4,7,2"/>
<TextBlock Text="{Binding Name}" Margin="2" VerticalAlignment="Center"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>

<DockPanel Grid.Row="2">
<Button x:Name="AboutButton"
DockPanel.Dock="Bottom"
Margin="10" Width="250"
HorizontalContentAlignment="Left"
Command="{Binding ViewModel.AboutCommand}">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe Fluent Icons" Margin="0 4 0 0">&#xE946;</TextBlock>
<TextBlock Text="About" Margin="8 0 0 0" />
</StackPanel>
</Button>
</DockPanel>
</Grid>
<Border Padding="16" Grid.Column="1" CornerRadius="8,0,0,0" Background="{DynamicResource SubtleFillColorSecondaryBrush}" Margin="12,12,0,0">
<Frame x:Name="RootContentFrame" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Win11ThemeGallery.Navigation;
using Win11ThemeGallery.Views;

namespace Win11ThemeGallery.ViewModels
{
public partial class AboutPageViewModel : ObservableObject
{
[ObservableProperty]
private string _pageTitle = "About";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public void Settings()
_navigationService.NavigateTo(typeof(SettingsPage));
}

[RelayCommand]
public void About()
{
_navigationService.NavigateTo(typeof(AboutPage));
}

[RelayCommand]
public void Back()
{
Expand Down
131 changes: 131 additions & 0 deletions Sample Applications/Win11ThemeGallery/Views/AboutPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<Page x:Class="Win11ThemeGallery.Views.AboutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Win11ThemeGallery.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AboutPage">
<Page.Resources>
<Style x:Key="LinkTextBlockStyle" TargetType="TextBlock">
<Setter Property="Margin" Value="0 4 0 4" />
</Style>
<Style x:Key="DefaultHyperlinkStyle" TargetType="Hyperlink">
<Setter Property="TextDecorations" Value="None" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" />
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="AboutCardStyle" TargetType="Border">
<Setter Property="Padding" Value="0 16 0 16" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
<Setter Property="BorderBrush" Value="{DynamicResource ExpanderHeaderBorderBrush}" />
</Style>

<Style x:Key="BottomAboutCardStyle" TargetType="Border">
<Setter Property="Padding" Value="0 16 0 16" />
</Style>
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<StackPanel Grid.Row="0" VerticalAlignment="Center" Margin="0 0 0 40">
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="{Binding ViewModel.PageTitle}" />
</StackPanel>

<StackPanel Margin="0,0,0,24" Grid.Row="1">
<Expander>
<Expander.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Image
Grid.Column="0"
VerticalAlignment="Center"
Source="pack://application:,,,/Assets/win11.png" Height="20" Width="20" Margin="10,5,10,5"/>

<StackPanel Orientation="Vertical" Grid.Column="1" Margin="10">
<TextBlock Text="WPF Win11 Gallery Application" />
<TextBlock Style="{StaticResource CaptionTextBlockStyle}" FontSize="11">© 2024 Microsoft. All rights reserved.</TextBlock>
</StackPanel>
</Grid>
</Expander.Header>
<Expander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Border Grid.Row="0" Style="{StaticResource AboutCardStyle}">
<Grid Margin="48 0 16 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="To Clone This Repository" Grid.Column="0" />
<TextBlock Text="git clone https://github.com/microsoft/WPF-Samples.git" Grid.Column="2" />
</Grid>
</Border>

<Border Grid.Row="1" Style="{StaticResource AboutCardStyle}">
<Grid Margin="48 0 16 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="File a bug or request a new sample" Grid.Column="0" />
<TextBlock FontFamily="Segoe Fluent Icons" Text="&#xe8a7;" Grid.Column="2" MouseDown="Open_Issues" />
</Grid>
</Border>

<Border Grid.Row="2" Style="{StaticResource AboutCardStyle}">
<StackPanel Orientation="Vertical" Margin="48 0 16 0">
<TextBlock Text="Dependencies and References" Margin="0 0 0 12" />
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Style="{StaticResource DefaultHyperlinkStyle}" Click="Open_ToolkitInformation">CommunityToolkit.Mvvm</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Style="{StaticResource DefaultHyperlinkStyle}" Click="Open_DIInformation">Microsoft.Extensions.DependencyInjection</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Style="{StaticResource DefaultHyperlinkStyle}" Click="Open_HostingInformation">Microsoft.Extensions.Hosting</Hyperlink>
</TextBlock>
</StackPanel>
</Border>

<Border Grid.Row="3" Style="{StaticResource BottomAboutCardStyle}">
<StackPanel Orientation="Vertical" Margin="48 0 16 0">
<TextBlock TextWrapping="Wrap" Text="THIS CODE AND INFORMATION IS PROVIDED ‘AS IS’ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE." Margin="0 0 0 12" />
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Style="{StaticResource DefaultHyperlinkStyle}"
Click="Services_Click">Microsoft Services Agreement</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource LinkTextBlockStyle}">
<Hyperlink Style="{StaticResource DefaultHyperlinkStyle}"
Click="Privacy_Click">Microsoft Privacy Statement</Hyperlink>
</TextBlock>
</StackPanel>
</Border>
</Grid>
</Expander.Content>
</Expander>
</StackPanel>
</Grid>
</Page>
63 changes: 63 additions & 0 deletions Sample Applications/Win11ThemeGallery/Views/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Win11ThemeGallery.ViewModels;

namespace Win11ThemeGallery.Views
{
/// <summary>
/// Interaction logic for AboutPage.xaml
/// </summary>
public partial class AboutPage : Page
{
public AboutPageViewModel ViewModel { get; }

public AboutPage(AboutPageViewModel viewModel)
{
ViewModel = viewModel;
DataContext = this;
InitializeComponent();
}

private void Services_Click(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://go.microsoft.com/fwlink/?LinkId=822631") { UseShellExecute = true });
}

private void Privacy_Click(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://go.microsoft.com/fwlink/?LinkId=521839") { UseShellExecute = true });
}

private void Open_Issues(object sender, MouseButtonEventArgs e)
{
Process.Start(new ProcessStartInfo("https://github.com/microsoft/WPF-Samples/issues/new") { UseShellExecute = true });
}

private void Open_ToolkitInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/CommunityToolkit.Mvvm/") { UseShellExecute = true });
}

private void Open_DIInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/Microsoft.Extensions.DependencyInjection/") { UseShellExecute = true });
}

private void Open_HostingInformation(object sender, RoutedEventArgs e)
{
Process.Start(new ProcessStartInfo("https://www.nuget.org/packages/Microsoft.Extensions.Hosting") { UseShellExecute = true });
}
}
}

0 comments on commit 9881800

Please sign in to comment.