I have ListView in my View whose itemsSource is bound to an Observable collection. this is my view
<ListView x:Name="Details"
ItemsSource="{Binding Details}"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="3">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Background="White" Width="350">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="175"/>
<ColumnDefinition Width="175"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="{Binding Key}"/>
<TextBox Grid.Row="0"
Grid.Column="1"
Text="{Binding Value}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Question: when i run my app and change my TextBox values, how do i get a new collection in my viewModel which has those changes ONLY? I want a collection of values i have changed Only. Currently i get a collection of values i have changed and old values . Here is my MainViewModel:
private ObservableCollection<Details> _details;
public ObservableCollection<Details> Details
{
get { return _details; }
set
{
_details= value;
RaisePropertyChanged();
}
}
public MainViewModel()
{
Details= new ObservableCollection<Details>
{
new Details() {Key = "age", Value = 25},
new Details() {Key = "sex", Value = "female"},
new Details() {Key = "height", Value = 3}
};
}
Details class:
public class Details
{
public string Key { get; set; }
public object Value { get; set;}}
In the above code if i change age to 20 ,,, i will get a collection of :(age 20, sex female,height 3) yet i only want (age 20) ,ie the Details object of the textBox i changed ONLY!!. I dont want to compare original collection and new collection to get that. Is there any way i can fire an event or something a long those lines.
Thanks