Skip to content

Commit 2f8d387

Browse files
Add another Adorner example with a TabViewItem InfoBadge adorner
TODO: Need to handle the Tab closing (i.e. AdornedElement unloads/disappears should also detach/remove adorner from AdornerLayer)
1 parent bb120de commit 2f8d387

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

components/Adorners/samples/Adorners.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ However, with an Adorner instead, you can abstract this behavior from the conten
3636

3737
> [!SAMPLE AdornersInfoBadgeSample]
3838
39+
You can see how Adorners react to more dynamic content, like a TabViewItem here:
40+
41+
> [!SAMPLE AdornersTabBadgeSample]
42+
3943
## Highlight Example
4044

4145
Adorners can be used in a variety of scenarios. For instance, if you wanted to highlight an element and show it's alignment to other elements in a creativity app:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!-- 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. -->
2+
<Page x:Class="AdornersExperiment.Samples.AdornersTabBadgeSample"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
8+
xmlns:ui="using:CommunityToolkit.WinUI"
9+
mc:Ignorable="d">
10+
11+
<muxc:TabView>
12+
<muxc:TabViewItem Header="Home">
13+
<ui:AdornerLayer.Xaml>
14+
<muxc:InfoBadge Margin="-4,-8"
15+
HorizontalAlignment="Left"
16+
VerticalAlignment="Top"
17+
IsHitTestVisible="False"
18+
Opacity="0.9"
19+
Visibility="{x:Bind IsAdornerVisible, Mode=OneWay}"
20+
Value="3" />
21+
</ui:AdornerLayer.Xaml>
22+
</muxc:TabViewItem>
23+
<muxc:TabViewItem Header="Document 1" />
24+
<muxc:TabViewItem Header="Document 2" />
25+
</muxc:TabView>
26+
</Page>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace AdornersExperiment.Samples;
6+
7+
[ToolkitSampleBoolOption("IsAdornerVisible", true, Title = "Is Adorner Visible")]
8+
9+
[ToolkitSample(id: nameof(AdornersTabBadgeSample), "InfoBadge w/ Adorner in TabView", description: "A sample for showing how add an InfoBadge to a TabViewItem via an Adorner.")]
10+
public sealed partial class AdornersTabBadgeSample : Page
11+
{
12+
public AdornersTabBadgeSample()
13+
{
14+
this.InitializeComponent();
15+
}
16+
}

0 commit comments

Comments
 (0)