Unable to update Collection bound to UI
This commit is contained in:
@@ -9,10 +9,11 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance Type={x:Type local:MainWindowViewModel}}"
|
d:DataContext="{d:DesignInstance Type={x:Type local:MainWindowViewModel}}"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid Background="DarkRed">
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition Height="auto"/>
|
<RowDefinition Height="auto"/>
|
||||||
|
<RowDefinition Height="auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ContentControl Grid.Row="0"
|
<ContentControl Grid.Row="0"
|
||||||
Visibility="Visible"
|
Visibility="Visible"
|
||||||
@@ -26,7 +27,9 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentControl.Resources>
|
</ContentControl.Resources>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
<Button Grid.Row="1"
|
<ListView Grid.Row="1"
|
||||||
|
ItemsSource="{Binding Strings}"/>
|
||||||
|
<Button Grid.Row="2"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Command="{Binding StartCommand}"
|
Command="{Binding StartCommand}"
|
||||||
Content="Start"/>
|
Content="Start"/>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -31,6 +32,7 @@ namespace WpfViewModelFirst
|
|||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine(c.Result);
|
System.Diagnostics.Debug.WriteLine(c.Result);
|
||||||
CurrentViewModel = new Part2ViewModel();
|
CurrentViewModel = new Part2ViewModel();
|
||||||
|
Strings.Add($"{DateTime.Now}");
|
||||||
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
}, TaskContinuationOptions.OnlyOnRanToCompletion);
|
||||||
//Task.Run(async () => await LongDelay()).ContinueWith(c =>
|
//Task.Run(async () => await LongDelay()).ContinueWith(c =>
|
||||||
// {
|
// {
|
||||||
@@ -48,5 +50,8 @@ namespace WpfViewModelFirst
|
|||||||
private ViewModelBase? _mainFrameViewModel;
|
private ViewModelBase? _mainFrameViewModel;
|
||||||
public ViewModelBase? CurrentViewModel { get => _mainFrameViewModel; set => SetProperty(ref _mainFrameViewModel, value); }
|
public ViewModelBase? CurrentViewModel { get => _mainFrameViewModel; set => SetProperty(ref _mainFrameViewModel, value); }
|
||||||
|
|
||||||
|
private ObservableCollection<string> _strings = new();
|
||||||
|
public ObservableCollection<string> Strings { get => _strings; set => SetProperty(ref _strings, value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user