Skip to content

Commit

Permalink
Merge pull request #20 from microsoft/master-update-to-winui2.4
Browse files Browse the repository at this point in the history
Update to WinUI 2.4
  • Loading branch information
Karl-Bridge-Microsoft authored Jun 25, 2020
2 parents b9d883d + e1a2c9a commit 8f335b7
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 42 deletions.
1 change: 1 addition & 0 deletions ContosoApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="/Styles/DataGrid.xaml" />
<ResourceDictionary Source="/Styles/Expander.xaml" />
<ResourceDictionary Source="/Styles/NavStyles.xaml" />
Expand Down
29 changes: 15 additions & 14 deletions ContosoApp/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="using:Contoso.App.UserControls"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
KeyDown="AppShell_KeyDown"
TabNavigation="Cycle"
mc:Ignorable="d">
Expand All @@ -33,41 +34,41 @@
x:Name="LayoutRoot"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<NavigationView
<MUXC:NavigationView
x:Name="NavView"
OpenPaneLength="160"
AlwaysShowHeader="False"
IsSettingsVisible="True"
ItemInvoked="NavigationView_ItemInvoked"
BackRequested="NavView_BackRequested"
BackRequested="NavigationView_BackRequested"
IsBackEnabled="{x:Bind AppFrame.CanGoBack, Mode=OneWay}">
<NavigationView.MenuItems>
<NavigationViewItem

<MUXC:NavigationView.MenuItems>
<MUXC:NavigationViewItem
x:Name="CustomerListMenuItem"
Content="{x:Bind CustomerListLabel}"
ToolTipService.ToolTip="{x:Bind CustomerListLabel}"
Icon="ContactInfo"/>
<NavigationViewItem
<MUXC:NavigationViewItem
x:Name="OrderListMenuItem"
Content="{x:Bind OrderListLabel}"
ToolTipService.ToolTip="{x:Bind OrderListLabel}"
Icon="Shop"/>
</NavigationView.MenuItems>
</MUXC:NavigationView.MenuItems>

<NavigationView.PaneFooter>
<MUXC:NavigationView.PaneFooter>
<StackPanel>
<NavigationViewItem
<MUXC:NavigationViewItem
Content="View code"
ToolTipService.ToolTip="View code"
Tapped="ViewCodeNavPaneButton_Tapped">
<NavigationViewItem.Icon>
<MUXC:NavigationViewItem.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE943;"/>
</NavigationViewItem.Icon>
</NavigationViewItem>
</MUXC:NavigationViewItem.Icon>
</MUXC:NavigationViewItem>
<uc:AuthenticationControl/>
</StackPanel>
</NavigationView.PaneFooter>
</MUXC:NavigationView.PaneFooter>

<!-- In OnNavigatingToPage, we synchronize the selected item in the NavigationView with the current page. -->
<Frame
Expand All @@ -85,7 +86,7 @@
</Frame.ContentTransitions>
</Frame>

</NavigationView>
</MUXC:NavigationView>
</Grid>
</Page>

4 changes: 2 additions & 2 deletions ContosoApp/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void AppShell_KeyDown(object sender, KeyRoutedEventArgs e)
/// <summary>
/// Navigates to the page corresponding to the tapped item.
/// </summary>
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
private void NavigationView_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
var label = args.InvokedItem as string;
var pageType =
Expand Down Expand Up @@ -156,7 +156,7 @@ await Launcher.LaunchUriAsync(new Uri(
/// <summary>
/// Navigates the frame to the previous page.
/// </summary>
private void NavView_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
private void NavigationView_BackRequested(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs args)
{
if (AppFrame.CanGoBack)
{
Expand Down
5 changes: 4 additions & 1 deletion ContosoApp/Contoso.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>ContosoApp</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19569.0</TargetPlatformVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -260,6 +260,9 @@
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.4.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ContosoModels\Contoso.Models.csproj">
Expand Down
5 changes: 3 additions & 2 deletions ContosoApp/Views/CustomerDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:stateTriggers="using:Contoso.App.StateTriggers"
xmlns:uc="using:Contoso.App.UserControls"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
NavigationCacheMode="Enabled"
mc:Ignorable="d">

Expand Down Expand Up @@ -62,7 +63,7 @@
Icon="Cancel"
Label="Cancel"
Visibility="{x:Bind ViewModel.IsInEdit, Mode=OneWay}" />
<AppBarSeparator Visibility="{x:Bind ViewModel.IsInEdit, Mode=OneWay}" />
<AppBarSeparator Visibility="{x:Bind ViewModel.IsInEdit, Mode=OneWay}" MaxHeight="40" />
<AppBarButton
Click="{x:Bind ViewModel.StartEdit}"
Icon="Edit"
Expand Down Expand Up @@ -298,7 +299,7 @@
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>

<ProgressBar
<MUXC:ProgressBar
Margin="0,48,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Expand Down
13 changes: 7 additions & 6 deletions ContosoApp/Views/CustomerListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
xmlns:stateTriggers="using:Contoso.App.StateTriggers"
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:uc="using:Contoso.App.UserControls"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
NavigationCacheMode="Required"
mc:Ignorable="d">

Expand All @@ -54,13 +55,13 @@
<TextBlock
x:Name="PageTitle"
Style="{StaticResource PageTitleTextBlockStyle}"
Text="Customers" />
Text="Customers"/>

<!--
On Windows 10, version 1607 or later, set DefaultLabelPosition to Right in code.
See CommandBar_Loaded event handler.
-->
<CommandBar
<CommandBar IsOpen="False"
x:Name="mainCommandBar"
HorizontalAlignment="Stretch"
Background="Transparent"
Expand All @@ -79,7 +80,7 @@
IsEnabled="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedCustomer), Mode=OneWay}"
Label="Add order"
ToolTipService.ToolTip="Add order" />
<AppBarSeparator />
<AppBarSeparator MaxHeight="40"></AppBarSeparator>
<AppBarButton
Click="CreateCustomer_Click"
Icon="Add"
Expand All @@ -91,14 +92,14 @@
Label="Sync"
ToolTipService.ToolTip="Sync with server" />
</CommandBar>

<uc:CollapsibleSearchBox
x:Name="CustomerSearchBox"
Width="240"
Margin="12,8,12,0"
CollapseWidth="{StaticResource LargeWindowSnapPoint}"
Loaded="CustomerSearchBox_Loaded"
RelativePanel.AlignRightWithPanel="True" />
RelativePanel.AlignRightWithPanel="True"/>

<Grid
Margin="0,10,0,0"
Expand Down Expand Up @@ -150,7 +151,7 @@
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>

<ProgressBar
<MUXC:ProgressBar
Margin="0,50,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Expand Down
3 changes: 2 additions & 1 deletion ContosoApp/Views/OrderListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:stateTriggers="using:Contoso.App.StateTriggers"
xmlns:uc="using:Contoso.App.UserControls"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
NavigationCacheMode="Required"
mc:Ignorable="d">

Expand Down Expand Up @@ -248,7 +249,7 @@
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>

<ProgressBar
<MUXC:ProgressBar
Margin="0,50,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Expand Down
21 changes: 6 additions & 15 deletions ContosoApp/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:MUXC="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
Expand All @@ -32,21 +33,11 @@
Style="{StaticResource PageTitleTextBlockStyle}"
Text="Settings" />

<TextBlock
Margin="0,25,0,5"
Text="Data source" />
<RadioButton
x:Name="SqliteRadio"
Checked="OnDataSourceChanged"
Content="Sqlite (Local)"
GroupName="DataSource"
Tag="Sqlite" />
<RadioButton
x:Name="RestRadio"
Checked="OnDataSourceChanged"
Content="REST (Azure)"
GroupName="DataSource"
Tag="Rest" />
<MUXC:RadioButtons Header="Data source" SelectedIndex="2">
<RadioButton Checked="OnDataSourceChanged" x:Name="SqliteRadio" Tag="Sqlite">Sqlite (Local)</RadioButton>
<RadioButton Checked="OnDataSourceChanged" x:Name="RestRadio" Tag="Rest">REST (Azure)</RadioButton>
</MUXC:RadioButtons>

<TextBlock Text="Data is read-only while using REST unless you deploy your own service. See the GitHub repository for details." />

<HyperlinkButton
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ and products for the fictitious company Contoso.
![ContosoApp screenshot 1](screenshot1.png)

## What's new
### June 2020 update

This update includes:

* Update to WinUI 2.4
* Add Microsoft.UI.Xaml NuGet package reference
* Update <Application.Resources> in App.xaml
* Refactoring for the following WinUI 2.4 controls:
* [ProgressBar](https://docs.microsoft.com/windows/uwp/design/controls-and-patterns/progress-controls)
* [NavigationView](https://docs.microsoft.com/windows/uwp/design/controls-and-patterns/navigationview)
* [RadioButtons](https://docs.microsoft.com/windows/uwp/design/controls-and-patterns/radio-button)
* Minor update to AppBarSeparator instances to correct unneccessary appearance of "More" button, and eliminate vertical shift of command buttons when the "More" button is clicked

## Previous updates

- Use of new controls like [DataGrid](https://docs.microsoft.com/windows/communitytoolkit/controls/datagrid),
[NavigationView](https://docs.microsoft.com/uwp/api/windows.ui.xaml.controls.navigationview), and
Expand Down

0 comments on commit 8f335b7

Please sign in to comment.