Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Samples/FocusVisuals/cs-winui/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<Application
x:Class="FocusVisualsSample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FocusVisualsSample">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
20 changes: 20 additions & 0 deletions Samples/FocusVisuals/cs-winui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
Comment thread
qiutongMS marked this conversation as resolved.

namespace FocusVisualsSample;

public partial class App : Application
{
public App()
{
InitializeComponent();
}

protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
var window = new MainWindow();
window.Activate();
}
}
Binary file added Samples/FocusVisuals/cs-winui/Assets/AppIcon.ico
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Samples/FocusVisuals/cs-winui/FocusVisualsSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net9.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>FocusVisualsSample</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" />
</ItemGroup>

<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<ItemGroup>
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.scale-200.png" />
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Assets\Square44x44Logo.targetsize-48_altform-lightunplated.png" />
<Content Include="Assets\StoreLogo.png" />
<Content Include="Assets\AppIcon.ico" />
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
<Content Include="Assets\yammer_share.png" />
</ItemGroup>

<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
Tools extension to be activated for this project even if the Windows App SDK Nuget
package has not yet been restored -->
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnablePreviewMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
</Project>
43 changes: 43 additions & 0 deletions Samples/FocusVisuals/cs-winui/FocusVisualsSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FocusVisualsSample", "FocusVisualsSample.csproj", "{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|Any CPU.ActiveCfg = Debug|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|Any CPU.Build.0 = Debug|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|ARM64.ActiveCfg = Debug|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|ARM64.Build.0 = Debug|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|ARM64.Deploy.0 = Debug|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|x64.ActiveCfg = Debug|x64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|x64.Build.0 = Debug|x64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|x64.Deploy.0 = Debug|x64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|x86.ActiveCfg = Debug|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Debug|x86.Build.0 = Debug|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|Any CPU.ActiveCfg = Release|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|Any CPU.Build.0 = Release|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|ARM64.ActiveCfg = Release|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|ARM64.Build.0 = Release|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|ARM64.Deploy.0 = Release|ARM64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|x64.ActiveCfg = Release|x64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|x64.Build.0 = Release|x64
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|x86.ActiveCfg = Release|x86
{BCDC1789-5958-4152-87F6-3BED4C6E4B2F}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
52 changes: 52 additions & 0 deletions Samples/FocusVisuals/cs-winui/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<Window
x:Class="FocusVisualsSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:FocusVisualsSample"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Focus Visuals Sample"
mc:Ignorable="d">
<Window.SystemBackdrop>
<MicaBackdrop />
</Window.SystemBackdrop>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TitleBar x:Name="AppTitleBar" Title="Focus Visuals Sample">
<TitleBar.IconSource>
<ImageIconSource ImageSource="Assets/AppIcon.ico" />
</TitleBar.IconSource>
</TitleBar>

<NavigationView
x:Name="NavView"
Grid.Row="1"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
SelectionChanged="NavView_SelectionChanged"
AutomationProperties.AutomationId="NavView">
<NavigationView.MenuItems>
<NavigationViewItem Content="Custom focus visuals" Tag="CustomFocusVisuals" AutomationProperties.AutomationId="NavItemCustomFocusVisuals">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE790;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
<NavigationViewItem Content="Custom control usage" Tag="CustomControlUsage" AutomationProperties.AutomationId="NavItemCustomControlUsage">
<NavigationViewItem.Icon>
<FontIcon Glyph="&#xE74C;" />
</NavigationViewItem.Icon>
</NavigationViewItem>
</NavigationView.MenuItems>

<Frame x:Name="ContentFrame" />
</NavigationView>
</Grid>
</Window>
41 changes: 41 additions & 0 deletions Samples/FocusVisuals/cs-winui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using FocusVisualsSample.Scenarios;

namespace FocusVisualsSample;

public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

ExtendsContentIntoTitleBar = true;
SetTitleBar(AppTitleBar);

AppWindow.SetIcon("Assets/AppIcon.ico");

// Select the first navigation item on startup.
NavView.SelectedItem = NavView.MenuItems[0];
}

private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
if (args.SelectedItem is NavigationViewItem item)
{
var tag = item.Tag?.ToString();
switch (tag)
{
case "CustomFocusVisuals":
ContentFrame.Navigate(typeof(CustomFocusVisualsPage));
break;
case "CustomControlUsage":
ContentFrame.Navigate(typeof(CustomControlUsagePage));
break;
}
}
}
}
51 changes: 51 additions & 0 deletions Samples/FocusVisuals/cs-winui/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">

<Identity
Name="756EB3FD-BD17-4AB4-83AE-342BF1467A92"
Publisher="CN=AppPublisher"
Version="1.0.0.0" />

<mp:PhoneIdentity PhoneProductId="756EB3FD-BD17-4AB4-83AE-342BF1467A92" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>FocusVisualsSample</DisplayName>
<PublisherDisplayName>AppPublisher</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.26226.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.26226.0" />
</Dependencies>

<Resources>
<Resource Language="x-generate"/>
</Resources>

<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="FocusVisualsSample"
Description="FocusVisualsSample"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
10 changes: 10 additions & 0 deletions Samples/FocusVisuals/cs-winui/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"FocusVisualsSample (Package)": {
"commandName": "MsixPackage"
},
"FocusVisualsSample (Unpackaged)": {
"commandName": "Project"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation.
Licensed under the MIT License. -->
<Page
x:Class="FocusVisualsSample.Scenarios.CustomControlUsagePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FocusVisualsSample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<ScrollViewer VerticalScrollMode="Auto" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="24" Spacing="16">
<TextBlock Text="Applying system focus visuals to custom controls" Style="{StaticResource SubtitleTextBlockStyle}" />
<RichTextBlock>
<Paragraph>The same focus visuals used for in-box controls can be applied to custom controls as well.</Paragraph>
<Paragraph>Simply set Control.UseSystemFocusVisuals to True, and it will draw the focus visuals around the bounds of your control.</Paragraph>
<Paragraph>If you need to specify a specific template part to be the bounds of the focus visual, use the attached property Control.IsTemplateFocusTarget and set it to true.</Paragraph>
</RichTextBlock>

<local:SocialMediaCounter ShareImage="ms-appx:///Assets/yammer_share.png" NavigateUri="https://www.yammer.com/" NumOfShares="12" VerticalAlignment="Top" AutomationProperties.AutomationId="SocialMediaCounterControl" AutomationProperties.Name="Share on Yammer" />
</StackPanel>
</ScrollViewer>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.UI.Xaml.Controls;

namespace FocusVisualsSample.Scenarios;

public sealed partial class CustomControlUsagePage : Page
{
public CustomControlUsagePage()
{
InitializeComponent();
}
}
Loading