-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(RadioButtons): Fix MaxColumns is not bound properly
- Loading branch information
1 parent
e8cb04c
commit 68c72c8
Showing
4 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...indows_UI_XAML_Controls/RadioButtonsTests/Controls/When_RadioButtons_TemplateBinding.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<UserControl | ||
x:Class="Uno.UI.Tests.Windows_UI_XAML_Controls.RadioButtonsTests.Controls.When_RadioButtons_TemplateBinding" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.Tests.Windows_UI_XAML_Controls.RadioButtonsTests.Controls" | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
|
||
<UserControl.Resources> | ||
<Style x:Key="MyStyle" TargetType="muxc:RadioButtons"> | ||
<Setter Property="IsTabStop" Value="False" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="muxc:RadioButtons"> | ||
<StackPanel> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal" /> | ||
<VisualState x:Name="Disabled"> | ||
<VisualState.Setters> | ||
<Setter Target="HeaderContentPresenter.Foreground" Value="{ThemeResource RadioButtonsHeaderForegroundDisabled}"/> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
<ContentPresenter x:Name="HeaderContentPresenter" | ||
Content="{TemplateBinding Header}" | ||
ContentTemplate="{TemplateBinding HeaderTemplate}" | ||
Foreground="{ThemeResource RadioButtonsHeaderForeground}" | ||
Margin="{ThemeResource RadioButtonsTopHeaderMargin}"/> | ||
<muxc:ItemsRepeater x:Name="InnerRepeater"> | ||
<muxc:ItemsRepeater.Layout> | ||
<primitives:ColumnMajorUniformToLargestGridLayout x:Name="InnerLayout" | ||
MaxColumns="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MaxColumns}" | ||
ColumnSpacing="{ThemeResource RadioButtonsColumnSpacing}" | ||
RowSpacing="{ThemeResource RadioButtonsRowSpacing}"/> | ||
</muxc:ItemsRepeater.Layout> | ||
</muxc:ItemsRepeater> | ||
</StackPanel> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</UserControl.Resources> | ||
|
||
<StackPanel Grid.Row="1" Orientation="Vertical"> | ||
<muxc:RadioButtons x:Name="rootRB" x:FieldModifier="public" MaxColumns="2" Style="{StaticResource MyStyle}"> | ||
</muxc:RadioButtons> | ||
</StackPanel> | ||
</UserControl> |
27 changes: 27 additions & 0 deletions
27
...ows_UI_XAML_Controls/RadioButtonsTests/Controls/When_RadioButtons_TemplateBinding.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace Uno.UI.Tests.Windows_UI_XAML_Controls.RadioButtonsTests.Controls | ||
{ | ||
public sealed partial class When_RadioButtons_TemplateBinding : UserControl | ||
{ | ||
public When_RadioButtons_TemplateBinding() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/Uno.UI.Tests/Windows_UI_XAML_Controls/RadioButtonsTests/Given_RadioButtons.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Uno.UI.Tests.Windows_UI_XAML_Controls.RadioButtonsTests.Controls; | ||
|
||
namespace Uno.UI.Tests.Windows_UI_XAML_Controls.RadioButtonsTests | ||
{ | ||
[TestClass] | ||
public class Given_RadioButtons | ||
{ | ||
[TestMethod] | ||
public void When_TemplateBinding() | ||
{ | ||
var SUT = new When_RadioButtons_TemplateBinding(); | ||
SUT.ForceLoaded(); | ||
|
||
var repeater = SUT.FindName("InnerRepeater") as ItemsRepeater; | ||
Assert.IsNotNull(repeater); | ||
|
||
var layout = repeater.Layout as ColumnMajorUniformToLargestGridLayout; | ||
|
||
Assert.AreEqual(2, layout.MaxColumns); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters