Browse Source

updated repro design.

pull/519/head
Dan Walmsley 10 years ago
parent
commit
8595eb58b3
  1. 32
      samples/XamlTestApplicationPcl/ViewModels/EditorViewModel.cs
  2. 3
      samples/XamlTestApplicationPcl/Views/MainWindow.xaml

32
samples/XamlTestApplicationPcl/ViewModels/EditorViewModel.cs

@ -1,4 +1,6 @@
namespace XamlTestApplication.ViewModels
using Perspex.Threading;
namespace XamlTestApplication.ViewModels
{
using ReactiveUI;
using System;
@ -19,6 +21,12 @@
{
Documents.Add(new EditorViewModel());
});
GCCommand = ReactiveCommand.Create();
GCCommand.Subscribe(_ =>
{
GC.Collect();
});
}
public static ShellViewModel Instance = new ShellViewModel();
@ -38,14 +46,28 @@
set { this.RaiseAndSetIfChanged(ref selectedDocument, value); }
}
private int instanceCount;
public int InstanceCount
{
get { return instanceCount; }
set { this.RaiseAndSetIfChanged(ref instanceCount, value); }
}
public ReactiveCommand<object> AddDocumentCommand { get; }
public ReactiveCommand<object> GCCommand { get; }
}
public class EditorViewModel : ReactiveObject
{
private static int InstanceCount = 0;
public EditorViewModel()
{
InstanceCount++;
ShellViewModel.Instance.InstanceCount = InstanceCount;
text = "This is some text.";
CloseCommand = ReactiveCommand.Create();
@ -58,6 +80,14 @@
~EditorViewModel()
{
//System.Console.WriteLine("EVM Destructed");
InstanceCount--;
Dispatcher.UIThread.InvokeAsync(() =>
{
ShellViewModel.Instance.InstanceCount = InstanceCount;
});
}

3
samples/XamlTestApplicationPcl/Views/MainWindow.xaml

@ -381,7 +381,8 @@
</TabStrip>
<Grid Background="#007ACC" Height="2" />
<Button Content="AddTab" Command="{Binding AddDocumentCommand}" Width="50" Height="30" />
<Button Content="GC.Collecy" Command="{Binding GCCommand}" Width="50" Height="30" />
<TextBox Text="{Binding InstanceCount}" />
<Carousel Items="{Binding Documents}" SelectedIndex="{Binding #strip.SelectedIndex}" IsVirtualized="false">
<Carousel.DataTemplates>

Loading…
Cancel
Save