Hi All,
I am using MVVM pattern in my WPF application. I am using the Modal created by Entity Framework and my ViewModel class have public properties for binding. I have a specific requirements that my GridView should have two checkboxes columns and one TextBox column (all time in Edit mode) and all other remaining columns will be in ReadOnly mode. When user either Check/Uncheck these checkboxes OR change value in TextBox, I will have to do custom calculation on it (Note that for firing these calculation, I should have separate property in ViewModel so that I can fire in its SET clause....Am I right?)
I created the Grid in XAML like this.
Here is my ViewModel
I am really stuck that how can I create properties for these check boxes and TextBox. Basically how can I get specific row DataItem in checkbox property so that I can return specific field from that DataItem.
Although my actual Model object is Entity Framework Model, but here is sample model for this example.
Any help please?
I am using MVVM pattern in my WPF application. I am using the Modal created by Entity Framework and my ViewModel class have public properties for binding. I have a specific requirements that my GridView should have two checkboxes columns and one TextBox column (all time in Edit mode) and all other remaining columns will be in ReadOnly mode. When user either Check/Uncheck these checkboxes OR change value in TextBox, I will have to do custom calculation on it (Note that for firing these calculation, I should have separate property in ViewModel so that I can fire in its SET clause....Am I right?)
I created the Grid in XAML like this.
<telerik:RadGridView Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="0" Name="radGridView1" AutoGenerateColumns="False" ShowGroupPanel="False" ItemsSource="{Binding IndicatorsList}"> <telerik:RadGridView.Columns> <col:MyColumn Header="#" Width="35"/> <telerik:GridViewColumn IsReadOnly="False" Header="Inc." Width="35"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding IncludeIt, Mode=TwoWay}"/> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewDataColumn Header="Indicator" DataMemberBinding="{Binding DisplayName}" IsReadOnly="True" Width="250" /> <telerik:GridViewColumn IsReadOnly="False" Header="Log" Width="35"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked="{Binding LOG, Mode=TwoWay}"/> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewColumn IsReadOnly="False" Header="Lag" Width="75"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding LAG, Mode=TwoWay}"/> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewColumn Header="Del." Width="35"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <telerik:RadButton Command="{Binding Delete}" CommandParameter="{Binding}" Width="27" Height="20"> <Image Source="/finStat.MacroVal.UI;component/Images/del_small.png"></Image> </telerik:RadButton> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>Here is my ViewModel
public List<Indicator> IndicatorsList { get { return Indicators.ToList(); } }public bool IncludeIt{ get { /******Here How I get current object item (i.e. Indicator) of the row so that I can return its value *********/ } set { /******Here How I get current object item (i.e. Indicator) of the row so that I set its value *********/ }}Although my actual Model object is Entity Framework Model, but here is sample model for this example.
public class Indicator{ public bool IncludeIndicator { get; set; } public string Name { get; set; } public bool Log { get; set; } public double Lag { get; set; }}Any help please?