diff --git a/WinUIGallery/App.xaml b/WinUIGallery/App.xaml index 39293dfa1..e0e2d8e3d 100644 --- a/WinUIGallery/App.xaml +++ b/WinUIGallery/App.xaml @@ -25,6 +25,8 @@ + + diff --git a/WinUIGallery/Pages/NavigationRootPage.xaml b/WinUIGallery/Pages/NavigationRootPage.xaml index b21d710ee..31c77a068 100644 --- a/WinUIGallery/Pages/NavigationRootPage.xaml +++ b/WinUIGallery/Pages/NavigationRootPage.xaml @@ -216,6 +216,11 @@ AutomationProperties.AutomationId="Templates" Content="Templates" Tag="Templates" /> + (int)GetValue(CountProperty); + set => SetValue(CountProperty, value); + } + + public CounterMode Mode + { + get => (CounterMode)GetValue(ModeProperty); + set => SetValue(ModeProperty, value); + } + + private Button ActionButton; + private TextBlock CountText; + + protected override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + ActionButton = GetTemplateChild(nameof(ActionButton)) as Button; + CountText = GetTemplateChild(nameof(CountText)) as TextBlock; + + if (ActionButton is not null) + { + ActionButton.Click += (sender, e) => + { + Count = Mode == CounterMode.Increment ? Count + 1 : Count - 1; + UpdateUI(); + }; + + UpdateButtonText(); + } + + UpdateUI(); + } + + private void UpdateUI() + { + if (CountText is not null) + { + CountText.Text = Count.ToString(); + } + } + + private void UpdateButtonText() + { + if (ActionButton is not null) + { + ActionButton.Content = Mode == CounterMode.Increment ? "Increase" : "Decrease"; + } + } +} + diff --git a/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/CounterControl.xaml b/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/CounterControl.xaml new file mode 100644 index 000000000..4ab127aea --- /dev/null +++ b/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/CounterControl.xaml @@ -0,0 +1,26 @@ + + + + + diff --git a/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/TemperatureConverterControl.xaml b/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/TemperatureConverterControl.xaml new file mode 100644 index 000000000..1125d7b92 --- /dev/null +++ b/WinUIGallery/Samples/ControlPages/Fundamentals/Controls/TemperatureConverterControl.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WinUIGallery/WinUIGallery.csproj b/WinUIGallery/WinUIGallery.csproj index 13a560571..4ecba44d8 100644 --- a/WinUIGallery/WinUIGallery.csproj +++ b/WinUIGallery/WinUIGallery.csproj @@ -295,6 +295,9 @@ + + + @@ -457,6 +460,32 @@ + + + + + + + + + + + + + MSBuild:Compile + + + + + + MSBuild:Compile + + + + + + MSBuild:Compile +