Good morning,
I would like to know if there is a way I can pull a property value from an ObservableCollection<SectionData> which is inside my View Model class. I can't find a way to do it. Here is my XAML:
I would like to know if there is a way I can pull a property value from an ObservableCollection<SectionData> which is inside my View Model class. I can't find a way to do it. Here is my XAML:
<telerikGridView:RadGridView.GroupHeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsChecked, Source={StaticResource FoodSafetyViewModel}, Mode=TwoWay}" Grid.Column="0"/>
<TextBlock Text="{Binding Section, Source={StaticResource FoodSafetyViewModel}, Mode=OneTime}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</telerikGridView:RadGridView.GroupHeaderTemplate>
Where FoodSafetyViewModel is defined as follows:
<navigation:Page.Resources>
<local:FoodSafetyViewModel x:Key="FoodSafetyViewModel"/>
</navigation:Page.Resources>
HEre is my ViewModel class:
namespace RemoteEntry.Classes
{
public class FoodSafetyViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private ObservableCollection<SectionData> sectionDatas;
private ObservableCollection<ViolationData> violationDatas;
private ObservableCollection<ViolationItemData> violationItemDatas;
private ObservableCollection<AutoCommentData> autoCommentDatas;
private object selectedItem;
public ObservableCollection<SectionData> SectionDatas
{
get
{
if (this.sectionDatas == null)
{
this.sectionDatas = SectionData.GetSectionData();
}
return this.sectionDatas;
}
}
public ObservableCollection<ViolationData> ViolationDatas
{
get
{
if (this.violationDatas == null)
{
this.violationDatas = ViolationData.GetViolationData();
}
return this.violationDatas;
}
}
...
and here is my SecionData class:
namespace RemoteEntry.Classes
{
public class SectionData : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private string section;
private bool isChecked;
public string Section
{
get { return this.section; }
set
{
if (value != this.section)
{
this.section = value;
this.OnPropertyChanged("Section");
}
}
}
public bool IsChecked
{
get { return this.isChecked; }
set
{
if (value != this.isChecked)
{
this.isChecked = value;
this.OnPropertyChanged("(IsChecked");
}
}
}
public SectionData()
{
}
public SectionData(string section, bool isChecked)
{
this.section = section;
this.isChecked = isChecked;
}
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, args);
}
}
private void OnPropertyChanged(string propertyName)
{
this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
See snapshot attached.
Any suggestions?