-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18695 from unoplatform/dev/mazi/xbind-to-const
- Loading branch information
Showing
7 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
48 changes: 48 additions & 0 deletions
48
src/Uno.UI.RuntimeTests/Tests/BindingTests/XBindConstControl.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,48 @@ | ||
<Control | ||
x:Class="Uno.UI.RuntimeTests.Tests.XBindConstControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
|
||
<Control.Resources> | ||
<ResourceDictionary> | ||
|
||
<Style TargetType="local:XBindConstControl"> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="local:XBindConstControl" > | ||
<Grid> | ||
<StackPanel | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<TextBlock Text="Grid in Control" HorizontalAlignment="Center" /> | ||
<Border | ||
Width="100" | ||
Height="100" | ||
BorderBrush="Black" | ||
BorderThickness="1" | ||
Background="LightCoral" /> | ||
<TextBlock Text="Grid in Control with x:Bind" HorizontalAlignment="Center" /> | ||
<Border | ||
Width="{x:Bind local:XBindConstControl.MyWidth}" | ||
Height="{x:Bind local:XBindConstControl.MyHeight}" | ||
x:Name="BoundBorder" | ||
BorderBrush="Black" | ||
BorderThickness="1" | ||
Background="LawnGreen" /> | ||
</StackPanel> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> | ||
</Control.Resources> | ||
|
||
</Control> |
27 changes: 27 additions & 0 deletions
27
src/Uno.UI.RuntimeTests/Tests/BindingTests/XBindConstControl.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 Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests; | ||
|
||
public sealed partial class XBindConstControl : Control | ||
{ | ||
private const double MyWidth = 200; | ||
private const double MyHeight = 200; | ||
|
||
public XBindConstControl() | ||
{ | ||
DefaultStyleKey = typeof(XBindConstControl); | ||
|
||
this.InitializeComponent(); | ||
} | ||
|
||
public Border XBoundBorder { get; set; } | ||
|
||
protected override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
|
||
XBoundBorder = GetTemplateChild("BoundBorder") as Border; | ||
|
||
|
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Uno.UI.RuntimeTests/Tests/BindingTests/XBindConstPage.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,29 @@ | ||
<Page x:Class="Uno.UI.RuntimeTests.Tests.XBindConstPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<ScrollViewer> | ||
<Grid> | ||
<StackPanel | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<TextBlock Text="Grid in Page" HorizontalAlignment="Center"/> | ||
<Grid | ||
Width="100" | ||
Height="100" | ||
BorderBrush="Black" | ||
BorderThickness="1" | ||
Background="LightCoral" /> | ||
<TextBlock Text="Grid in Page, with x:Bind" HorizontalAlignment="Center" /> | ||
<Border | ||
Width="{x:Bind local:XBindConstPage.MyWidth}" | ||
Height="{x:Bind local:XBindConstPage.MyHeight}" | ||
x:Name="BoundBorder" | ||
BorderBrush="Black" | ||
BorderThickness="1" | ||
Background="LawnGreen" /> | ||
</StackPanel> | ||
</Grid> | ||
</ScrollViewer> | ||
</Page> |
16 changes: 16 additions & 0 deletions
16
src/Uno.UI.RuntimeTests/Tests/BindingTests/XBindConstPage.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,16 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests; | ||
|
||
public sealed partial class XBindConstPage : Page | ||
{ | ||
private const double MyWidth = 200; | ||
private const double MyHeight = 200; | ||
|
||
public XBindConstPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
public Border XBoundBorder => BoundBorder; | ||
} |