Hello
I have a XamGrid, First Column is checkboxcolumn.
When User check the checkboxcolumn, I want to know row data that checkboxcolumn is checked.
and I want to know row count that checkboxcolumn is checked, in XamGrid
and Next I want to Add the Event, that at once check or uncheck All Checkboxcolumn.
Please Let me know that how ...
Hello,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thank you for your reply. I have been looking into the modified code, that you have provided me with and it seems that the reason for the RowChanged event to not fire is that the event is actually handled for the original DataTable, which is set to the Data property in the constructor of the MainViewModel. When you setting the Data property of the Click event of a Button, the RowChanged event is not actually handled for the new DataTable that is assigned to the Data property. What I can suggest in this scenario is creating a method that updates the property for the checked rows, handle the RowChanged event of the new value of Data property and call that method in the event handler. I have modified the sample application I have previously set to you, in order to demonstrates how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Thank you for your sample code. I Using your sample code in my Application.
I modified my code, referencing your sample. like below.
But, "DataRowChangeEvent" do not active. I don't know what is problem.
public partial class MainWindow : Window
{
public MainWindow()
InitializeComponent();
setGrid();
DataContext = new MainViewModel();
}
private void btnSrch_Click(object sender, RoutedEventArgs e)
DBAgent _oDBAgent = new DBAgent();
_oDBAgent.Open();
Object[] _aParam = new Object[] { "BDOA", "6046", "P", "E", "", "1','3" };
DataSet oDataSet = _oDBAgent.ExecuteSaveViaFDOAS00L("BDOA", "selEquipTagHead", _aParam);
(DataContext as MainViewModel).Data = oDataSet.Tables[0];
dgdDisplay.ItemsSource = (DataContext as MainViewModel).Data.DefaultView;
_oDBAgent.Close();
private void setGrid()
CheckBoxColumn oSEL = new CheckBoxColumn { Key = "SEL", HeaderTemplate = CreateHeaderTemplate("SEL"), IsSummable = false };
TextColumn oPROJ_NO = new TextColumn { Key = "PROJ_NO", HeaderTemplate = CreateHeaderTemplate("PROJ_NO"), IsReadOnly = true };
TextColumn oBOM_CLSF = new TextColumn { Key = "BOM_CLSF", HeaderTemplate = CreateHeaderTemplate("BOM_CLSF"), IsReadOnly = true };
TextColumn oDSGN_SMBL = new TextColumn { Key = "DSGN_SMBL", HeaderTemplate = CreateHeaderTemplate("DSGN_SMBL"), IsReadOnly = true };
TextColumn oDSGN_APPL = new TextColumn { Key = "DSGN_APPL", HeaderTemplate = CreateHeaderTemplate("DSGN_APPL"), IsReadOnly = true };
TextColumn oBOM_NO = new TextColumn { Key = "BOM_NO", HeaderTemplate = CreateHeaderTemplate("BOM_NO"), IsReadOnly = true };
TextColumn oBOM_DESC = new TextColumn { Key = "BOM_DESC", HeaderTemplate = CreateHeaderTemplate("BOM_DESC"), IsReadOnly = true };
dgdDisplay.Columns.Add(oSEL);
dgdDisplay.Columns.Add(oPROJ_NO);
dgdDisplay.Columns.Add(oBOM_CLSF);
dgdDisplay.Columns.Add(oDSGN_SMBL);
dgdDisplay.Columns.Add(oDSGN_APPL);
dgdDisplay.Columns.Add(oBOM_NO);
dgdDisplay.Columns.Add(oBOM_DESC);
public DataTemplate CreateHeaderTemplate(string sColHeader)
string template =
@"<DataTemplate
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<StackPanel>
<TextBlock TextWrapping = ""Wrap"" Text=""" + sColHeader + @""" />
</StackPanel>
</DataTemplate>";
return XamlReader.Parse(template) as DataTemplate;
private void chkSelAll_Click(object sender, RoutedEventArgs e)
(DataContext as MainViewModel).CheckUncheckAll((bool)(sender as CheckBox).IsChecked);
public class MainViewModel : INotifyPropertyChanged
int selectedCount;
public MainViewModel()
Data = new DataTable();
Data.RowChanged += (s, e) =>
int temp = 0;
foreach (DataRow r in Data.Rows)
if ((bool)r.ItemArray[0])
temp++;
AllSelectedCount = temp;
};
AllSelectedCount = 0;
private void DataTable_RowChanged(object sender, DataRowChangeEventArgs e)
public void CheckUncheckAll(bool check)
r[0] = check;
r.AcceptChanges();
Data.AcceptChanges();
public int AllSelectedCount
get
return selectedCount;
set
selectedCount = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("AllSelectedCount"));
public DataTable Data { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
Thank you for your reply. I have been looking into your question and I can suggest using the RowChanged event of the DataTable, in order to update the property that returns the count of the checked rows. I have modified the sample application that I have sent to you with my previous reply, in order to use implement the same functionality, when using DataTable.
Hello, Krasimir
Thank you for your help.
I see your sample code, then I have a Question.
You using "ObservableCollection", but I bind Dataview to XamGrid like below.
DataSet _oDataSet = ...("Select...."SQL Result);
oXamGrid.ItemSource = _oDataSet.Tables[0].DefaultView;
In my Case, can I Use "PropertyChangedEvent" for getting checked Row Data and checked Row count.