Skip to content

Commit

Permalink
Update the sample code to match the actual code (microsoft#1709)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
This PR updates the sample code on the `TeachingTip` page to match the
actual code.

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
The current sample code doesn't match the actual code and doesn't even
compile.

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Ran the app and confirmed its contents.

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
AndrewKeepCoding authored Jan 10, 2025
1 parent b317539 commit f22541c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
30 changes: 17 additions & 13 deletions WinUIGallery/ControlPages/TeachingTipPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
<StackPanel HorizontalAlignment="Left">
<local:ControlExample
CSharpSource="TeachingTip/TeachingTipSample1_cs.txt"
HeaderText="Show a targeted TeachingTip on the Toggle Theme button."
HeaderText="Show a targeted TeachingTip on a button."
XamlSource="TeachingTip/TeachingTipSample1_xaml.txt">
<local:ControlExample.Example>
<Grid>
<Button
x:Name="ThemeButton"
Click="TestButtonClick1"
x:Name="TestButton1"
Click="TestButton1Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="ToggleThemeTeachingTip1"
x:Name="TestButton1TeachingTip"
Title="This is the title"
Subtitle="And this is the subtitle"
Target="{x:Bind ThemeButton}">
Target="{x:Bind TestButton1}">
<TeachingTip.IconSource>
<SymbolIconSource Symbol="Refresh" />
</TeachingTip.IconSource>
Expand All @@ -47,9 +47,11 @@
XamlSource="TeachingTip/TeachingTipSample2_xaml.txt">
<local:ControlExample.Example>
<Grid>
<Button Click="TestButtonClick2" Content="Show TeachingTip" />
<Button
Click="TestButton2Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="ToggleThemeTeachingTip2"
x:Name="TestButton2TeachingTip"
Title="This is the title"
ActionButtonContent="Action button"
CloseButtonContent="Close button"
Expand All @@ -63,22 +65,24 @@

<local:ControlExample
CSharpSource="TeachingTip/TeachingTipSample3_cs.txt"
HeaderText="Show a targeted TeachingTip with hero content on the Toggle Theme button."
HeaderText="Show a targeted TeachingTip with hero content on a button."
XamlSource="TeachingTip/TeachingTipSample3_xaml.txt">
<local:ControlExample.Example>
<Grid>
<Button
x:Name="HeroButton"
Click="TestButtonClick3"
x:Name="TestButton3"
Click="TestButton3Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="ToggleThemeTeachingTip3"
x:Name="TestButton3TeachingTip"
Title="This is the title"
PreferredPlacement="Bottom"
Subtitle="And this is the subtitle"
Target="{x:Bind HeroButton}">
Target="{x:Bind TestButton3}">
<TeachingTip.HeroContent>
<Image AutomationProperties.Name="Sunset" Source="/Assets/SampleMedia/sunset.jpg" />
<Image
AutomationProperties.Name="Sunset"
Source="/Assets/SampleMedia/sunset.jpg" />
</TeachingTip.HeroContent>
<TeachingTip.Content>
<TextBlock
Expand Down
12 changes: 6 additions & 6 deletions WinUIGallery/ControlPages/TeachingTipPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ public TeachingTipPage()
this.InitializeComponent();
}

private void TestButtonClick1(object sender, RoutedEventArgs e)
private void TestButton1Click(object sender, RoutedEventArgs e)
{
ToggleThemeTeachingTip1.IsOpen = true;
TestButton1TeachingTip.IsOpen = true;
}

private void TestButtonClick2(object sender, RoutedEventArgs e)
private void TestButton2Click(object sender, RoutedEventArgs e)
{
ToggleThemeTeachingTip2.IsOpen = true;
TestButton2TeachingTip.IsOpen = true;
}

private void TestButtonClick3(object sender, RoutedEventArgs e)
private void TestButton3Click(object sender, RoutedEventArgs e)
{
ToggleThemeTeachingTip3.IsOpen = true;
TestButton3TeachingTip.IsOpen = true;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<Button Content="Show TeachingTip" Click="TestButtonClick1" />

<TeachingTip x:Name="ToggleThemeTeachingTip1"
Target="{x:Bind ThemeButton}"
Title="Change themes without hassle"
Subtitle="It's easier than ever to see control samples in both light and dark theme!">
<Button
x:Name="TestButton1"
Click="TestButton1Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="TestButton1TeachingTip"
Title="This is the title"
Subtitle="And this is the subtitle"
Target="{x:Bind TestButton1}">
<TeachingTip.IconSource>
<SymbolIconSource Symbol="Refresh" />
</TeachingTip.IconSource>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Button Content="Show TeachingTip" Click="TestButtonClick2" />

<TeachingTip x:Name="ToggleThemeTeachingTip2"
Title="Change themes without hassle"
Subtitle="It's easier than ever to see control samples in both light and dark theme!"
PreferredPlacement="Auto"
PlacementMargin="20"
IsLightDismissEnabled="True"
ActionButtonClick="ToggleThemeTeachingTip2_ActionButtonClick"
ActionButtonContent="Toggle theme now"
CloseButtonContent="Got it!">
</TeachingTip>
<Button
Click="TestButton2Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="TestButton2TeachingTip"
Title="This is the title"
ActionButtonContent="Action button"
CloseButtonContent="Close button"
IsLightDismissEnabled="True"
PlacementMargin="20"
PreferredPlacement="Auto"
Subtitle="And this is the subtitle" />
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
<Button Content="Show TeachingTip" Click="TestButtonClick3" />

<TeachingTip x:Name="ToggleThemeTeachingTip3"
Target="{x:Bind ThemeButton}"
Title="Change themes without hassle"
Subtitle="It's easier than ever to see control samples in both light and dark theme!"
PreferredPlacement="LeftEdgeAlignedBottom">
<Button
x:Name="TestButton3"
Click="TestButton3Click"
Content="Show TeachingTip" />
<TeachingTip
x:Name="TestButton3TeachingTip"
Title="This is the title"
PreferredPlacement="Bottom"
Subtitle="And this is the subtitle"
Target="{x:Bind TestButton3}">
<TeachingTip.HeroContent>
<Image Source="/Assets/SampleMedia/sunset.jpg" AutomationProperties.Name="Sunset" />
<Image
AutomationProperties.Name="Sunset"
Source="/Assets/SampleMedia/sunset.jpg" />
</TeachingTip.HeroContent>
<TeachingTip.Content>
<TextBlock TextWrapping="WrapWholeWords" Margin="0,16,0,0">To change your desktop theme visit the <Hyperlink NavigateUri="ms-settings:colors">Settings app</Hyperlink>.</TextBlock>
<TextBlock
Margin="0,16,0,0"
Text="Description can go here"
TextWrapping="WrapWholeWords" />
</TeachingTip.Content>
</TeachingTip>

0 comments on commit f22541c

Please sign in to comment.