Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
SettingsCard é um controle que pode ser usado para exibir as configurações em sua experiência. Ele usa o estilo padrão encontrado no Windows 11 e é fácil de usar, atende a todos os padrões de acessibilidade e fará com que a página de configurações fique ótima!
Você pode definir as propriedades Header, Description, HeaderIcon e Content para criar uma experiência fácil de usar, da seguinte maneira:
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="SettingsControlsExperiment.Samples.SettingsCardSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
<StackPanel Spacing="4">
<controls:SettingsCard x:Name="settingsCard"
Description="This is a default card, with the Header, HeaderIcon, Description and Content set."
Header="This is the Header"
HeaderIcon="{ui:FontIcon Glyph=}"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<ComboBox SelectedIndex="0">
<ComboBoxItem>Option 1</ComboBoxItem>
<ComboBoxItem>Option 2</ComboBoxItem>
<ComboBoxItem>Option 3</ComboBoxItem>
</ComboBox>
</controls:SettingsCard>
<controls:SettingsCard Description="You can use a FontIcon, SymbolIcon or BitmapIcon to set the cards HeaderIcon."
Header="Icon options"
HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/AppTitleBar.scale-200.png}"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<ToggleSwitch />
</controls:SettingsCard>
<controls:SettingsCard Header="A card with custom objects as its Description"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<controls:SettingsCard.Description>
<HyperlinkButton Content="Learn more about Phone Link" />
</controls:SettingsCard.Description>
<Button Content="Open Phone Link"
Style="{StaticResource AccentButtonStyle}" />
</controls:SettingsCard>
<controls:SettingsCard Description="When resizing a SettingsCard, the Content will wrap vertically. You can override this breakpoint by setting the SettingsCardWrapThreshold resource. For edge cases, you can also hide the icon by setting SettingsCardWrapNoIconThreshold."
Header="Adaptive layouts"
HeaderIcon="{ui:FontIcon Glyph=}"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<controls:SettingsCard.Resources>
<x:Double x:Key="SettingsCardWrapThreshold">800</x:Double>
<x:Double x:Key="SettingsCardWrapNoIconThreshold">600</x:Double>
</controls:SettingsCard.Resources>
<Button Content="This control will wrap vertically!"
Style="{StaticResource AccentButtonStyle}" />
</controls:SettingsCard>
<controls:SettingsCard Header="This is a card with a Header only" />
</StackPanel>
</Page>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace SettingsControlsExperiment.Samples;
[ToolkitSampleBoolOption("IsCardEnabled", true, Title = "Is Enabled")]
[ToolkitSample(id: nameof(SettingsCardSample), "SettingsCard", description: "A sample for showing how SettingsCard can be static or clickable.")]
public sealed partial class SettingsCardSample : Page
{
public SettingsCardSample()
{
this.InitializeComponent();
}
}
Para transformar SettingsCard em um botão, basta definir a propriedade IsClickEnabled. Isso pode ser útil sempre que você quiser que seu componente de configurações navegue até uma página de detalhes ou abra um link externo. Você pode definir um ícone personalizado definindo ActionIcon ou ocultando-o completamente definindo IsActionIconVisible comofalse.
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="SettingsControlsExperiment.Samples.ClickableSettingsCardSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
<StackPanel Spacing="4">
<controls:SettingsCard x:Name="settingsCard"
Click="OnCardClicked"
Description="A SettingsCard can be made clickable and you can leverage the Command property or Click event."
Header="A clickable SettingsCard"
HeaderIcon="{ui:FontIcon Glyph=}"
IsClickEnabled="True"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}">
<TextBlock Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="This is content" />
</controls:SettingsCard>
<controls:SettingsCard ActionIcon="{ui:FontIcon Glyph=}"
ActionIconToolTip="Open in new window"
Click="OnCardClicked"
Description="You can customize the ActionIcon and ActionIconToolTip."
Header="Customizing the ActionIcon"
HeaderIcon="{ui:FontIcon Glyph=}"
IsClickEnabled="True"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}" />
<controls:SettingsCard Click="OnCardClicked"
Header="Hiding the ActionIcon"
HeaderIcon="{ui:FontIcon Glyph=}"
IsActionIconVisible="False"
IsClickEnabled="True"
IsEnabled="{x:Bind IsCardEnabled, Mode=OneWay}" />
</StackPanel>
</Page>
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
namespace SettingsControlsExperiment.Samples;
[ToolkitSampleBoolOption("IsCardEnabled", true, Title = "Is Enabled")]
[ToolkitSample(id: nameof(ClickableSettingsCardSample), "ClickableSettingsCardSample", description: "A sample for showing how SettingsCard can be static or clickable.")]
public sealed partial class ClickableSettingsCardSample : Page
{
public ClickableSettingsCardSample()
{
this.InitializeComponent();
}
private async void OnCardClicked(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("https://www.microsoft.com"));
}
}
Windows Community Toolkit