c# - How to get binding expression of a datagrid column? -


How can I get the binding expression of a datagrid column in WPF?

This is XAML for columns:

  & lt; DataGridTextColumn x: name = "zodiac column" header = "zodiac" width = "100" binding = "{binding_amount, stringformat = c}" cellstyle = "{statatic resource errorstyle}" />  

I use this code to get all the binding expressions in a data grid :

  Private GetAllBindingsInDatagrid (DataGrid DG) {archive bindings = new archive (); If (dg.ItemsSource! = Null) {foreach (in object items dg.ItemsSource) {DataGridRow row = dg.ItemContainerGenerator.ContainerFromItem (item); If (line! = Null) {foreach (Binding Experiment Binding in the line. Binding Group. Binding Expressions) {Binding.ed (binding); }}}} Return binding; }  

Edit: Since the question was to obtain a "binding expression" of a column, which refers to an example of a binding, I thought the objective was to check whether someone Verification is errors or something else, so it repeats the above rows. But if the column requires generic "binding" (for example, to dynamically add a validation rule) this code can be used:

  // datagrid as DataGridTextColumn Retrieve the first DataGrid object Column = datagrid.FindName ("Zodiac Column"); Binding binding = column Binding;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -