-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workaround so ItemsRepeater doesn't leak the result of DataTempla…
…te::Load (microsoft/microsoft-ui-xaml#3068)
- Loading branch information
Showing
8 changed files
with
159 additions
and
12 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
14 changes: 14 additions & 0 deletions
14
test/ModernWpfTestApp/Samples/ItemTemplateSamples/DisposableUserControl.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,14 @@ | ||
<UserControl | ||
x:Class="MUXControlsTestApp.Samples.DisposableUserControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
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"> | ||
|
||
<Grid> | ||
<TextBlock Text="{x:Bind Number}"/> | ||
</Grid> | ||
</UserControl> |
36 changes: 36 additions & 0 deletions
36
test/ModernWpfTestApp/Samples/ItemTemplateSamples/DisposableUserControl.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,36 @@ | ||
using System.Threading; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace MUXControlsTestApp.Samples | ||
{ | ||
public sealed partial class DisposableUserControl : UserControl | ||
{ | ||
|
||
public int Number | ||
{ | ||
get { return (int)GetValue(NumberProperty); } | ||
set { SetValue(NumberProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty NumberProperty = | ||
DependencyProperty.Register("Number", typeof(int), typeof(DisposableUserControl), new PropertyMetadata(-1)); | ||
|
||
|
||
public static int OpenItems { get { return _counter; } } | ||
private static int _counter = 0; | ||
|
||
public DisposableUserControl() | ||
{ | ||
Interlocked.Increment(ref _counter); | ||
this.InitializeComponent(); | ||
} | ||
|
||
~DisposableUserControl() | ||
{ | ||
Interlocked.Decrement(ref _counter); | ||
} | ||
} | ||
} |
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
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