-
Notifications
You must be signed in to change notification settings - Fork 749
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 #14759 from unoplatform/mergify/bp/release/stable/…
…5.0/pr-14737 x:Bind to event in `ResourceDictionary` (backport #14737)
- Loading branch information
Showing
6 changed files
with
95 additions
and
0 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
30 changes: 30 additions & 0 deletions
30
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/XBind_ResourceDictionary.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,30 @@ | ||
<ResourceDictionary | ||
x:Class="Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls.XBind_ResourceDictionary" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls"> | ||
|
||
<!-- Implicitly applied default style --> | ||
<Style BasedOn="{StaticResource DefaultxBindProjectTemplateStyle}" TargetType="controls:XBind_ResourceDictionary_Control" /> | ||
|
||
<Style x:Key="DefaultxBindProjectTemplateStyle" TargetType="controls:XBind_ResourceDictionary_Control"> | ||
<Style.Setters> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="controls:XBind_ResourceDictionary_Control"> | ||
<ContentControl | ||
x:Name="ContentContainer" | ||
HorizontalContentAlignment="Stretch" | ||
VerticalContentAlignment="Stretch"> | ||
<ContentControl.ContentTemplate> | ||
<DataTemplate x:DataType="controls:XBind_ResourceDictionary_Control"> | ||
<Button Content="Hello" Loaded="{x:Bind Element_Loaded}" /> | ||
</DataTemplate> | ||
</ContentControl.ContentTemplate> | ||
</ContentControl> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style.Setters> | ||
</Style> | ||
</ResourceDictionary> |
23 changes: 23 additions & 0 deletions
23
src/Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/XBind_ResourceDictionary.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,23 @@ | ||
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; | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls; | ||
public sealed partial class XBind_ResourceDictionary : ResourceDictionary | ||
{ | ||
public XBind_ResourceDictionary() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...Uno.UI.Tests/Windows_UI_Xaml_Data/xBindTests/Controls/XBind_ResourceDictionary_Control.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 Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace Uno.UI.Tests.Windows_UI_Xaml_Data.xBindTests.Controls; | ||
|
||
internal class XBind_ResourceDictionary_Control : Control | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="ProjectTemplate_xBind"/> class. | ||
/// </summary> | ||
public XBind_ResourceDictionary_Control() | ||
{ | ||
this.DefaultStyleKey = typeof(XBind_ResourceDictionary_Control); | ||
|
||
// Allows directly using this control as the x:DataType in the template. | ||
this.DataContext = this; | ||
} | ||
|
||
public bool ElementLoadedInvoked { get; private set; } | ||
|
||
public void Element_Loaded(object sender, RoutedEventArgs args) | ||
{ | ||
ElementLoadedInvoked = true; | ||
} | ||
} |
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