Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update NumberBox example to reflect spin button placement in displayed XAML code #1612

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
1 change: 0 additions & 1 deletion WinUIGallery/ContentIncludes.props
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
<Content Include="ControlPagesSampleCode\NavigationView\NavigationViewSample6.txt" />
<Content Include="ControlPagesSampleCode\NavigationView\NavigationViewSample8_xaml.txt" />
<Content Include="ControlPagesSampleCode\NavigationView\NavigationViewSample9_xaml.txt" />
<Content Include="ControlPagesSampleCode\NumberBox\NumberBoxSample2_xaml.txt" />
<Content Include="ControlPagesSampleCode\NumberBox\NumberBoxSample3_cs.txt" />
<Content Include="ControlPagesSampleCode\NumberBox\NumberBoxSample3_xaml.txt" />
<Content Include="ControlPagesSampleCode\System\FilePickerSample1_cs.txt" />
Expand Down
27 changes: 20 additions & 7 deletions WinUIGallery/ControlPages/NumberBoxPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
</x:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample HeaderText="A NumberBox with a spin button."
XamlSource="NumberBox/NumberBoxSample2_xaml.txt">

<local:ControlExample HeaderText="A NumberBox with a spin button.">
<local:ControlExample.Example>
<NumberBox x:Name="NumberBoxSpinButtonPlacementExample"
VerticalAlignment="Top"
Expand All @@ -44,13 +43,27 @@
</NumberBox>
</local:ControlExample.Example>
<local:ControlExample.Options>
<RadioButtons x:Name="SpinButtonPlacementGroup" Header="SpinButton placement">
<RadioButton Content="Inline" Tag="Inline" Checked="RadioButton_Checked" />
<RadioButton Content="Compact" Tag="Compact" Checked="RadioButton_Checked" IsChecked="True" />
<RadioButtons x:Name="SpinButtonPlacementGroup" Header="SpinButton placement" SelectedIndex="0" SelectionChanged="SpinButtonPlacementGroup_SelectionChanged">
<x:String>Inline</x:String>
<x:String>Compact</x:String>
</RadioButtons>
</local:ControlExample.Options>
<local:ControlExample.Xaml>
<x:String xml:space="preserve">
&lt;NumberBox
x:Name="NumberBoxSpinButtonPlacementExample"
Header="Enter an integer:"
Value="1"
SpinButtonPlacementMode="$(SpinButtonPlacementMode)"
SmallChange="10"
LargeChange="100" /&gt;
</x:String>
</local:ControlExample.Xaml>
<local:ControlExample.Substitutions>
<local:ControlExampleSubstitution Key="SpinButtonPlacementMode" Value="{x:Bind SpinButtonPlacementGroup.SelectedItem, Mode=OneWay}"/>
</local:ControlExample.Substitutions>
</local:ControlExample>

<local:ControlExample HeaderText="A formatted NumberBox that rounds to the nearest 0.25."
XamlSource="NumberBox/NumberBoxSample3_xaml.txt"
CSharpSource="NumberBox/NumberBoxSample3_cs.txt">
Expand Down
12 changes: 5 additions & 7 deletions WinUIGallery/ControlPages/NumberBoxPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ private void SetNumberBoxNumberFormatter()
FormattedNumberBox.NumberFormatter = formatter;
}

private void RadioButton_Checked(object sender, RoutedEventArgs e)
private void SpinButtonPlacementGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is RadioButton rb && NumberBoxSpinButtonPlacementExample != null)
if (sender is RadioButtons radioButtons)
{
string spinButtonPlacementModeName = rb.Tag.ToString();

switch (spinButtonPlacementModeName)
switch (radioButtons.SelectedIndex)
{
case "Inline":
case 0:
NumberBoxSpinButtonPlacementExample.SpinButtonPlacementMode = NumberBoxSpinButtonPlacementMode.Inline;
break;
case "Compact":
case 1:
NumberBoxSpinButtonPlacementExample.SpinButtonPlacementMode = NumberBoxSpinButtonPlacementMode.Compact;
break;
}
Expand Down

This file was deleted.