pi = typeof(CfgPartPrograms).GetProperty(be.ParentBinding.Path. Object cfgPartPrograms = textBlock.DataContext If (be != null & be.ParentBinding != null & be.ParentBinding.Path != null & !string.IsNullOrEmpty(be.)) String str = (tbxSrc.Text, tbxDest.Text) Ä«indingExpression be = textBlock.GetBindingExpression(TextBlock.TextProperty) TextBlock textBlock = (TextBlock)content You could then use reflection to set the property to a new value: DataGridRow row = (DataGridRow)(iii) If the TextBlock is bound to a source property of the CfgPartPrograms object, you could get the name of this property using the GetBindingExpression method. Obc.SetValue(numRow, numCol, strNewValue) If (t = typeof(string) & propCounter = propNumFromZero) Public static ObservableCollection SetValue(this ObservableCollection obc, int rowNumFromZero, int propNumFromZero, string str) You might even use extensions: public static class ObservableCollectionExtensions Var currentField = field.GetValue(itemObc, null) PropertyInfo Fields = itemObc.GetType().GetProperties() We can modify it with: foreach (var itemObc in obc) So now we can create and fill the obc: var obc = new ObservableCollection() Public Målass(string _s1, string _s2, string _s3) Imagine having the following class: public class Målass I would like to be able to automatically change obc.X = "AAAAAA" I am able to change the datagrid -> dtgFeatures = "AAAAAA" Ä¢. with string compare) edit the datagrid and reflect the changes on the obc?Äatagrid AUTOMATIC EDIT -> changes on observable collectionÄ¡. Why not having the possibility of PROGRAMMATICALLY (e.g. Since I can MANUALLY edit the datagrid and reflect the changes on the observable collectionÄatagrid MANUAL EDIT -> changes on observable collection So I have a very large number of properties (here 9 but potentially many many more) so I would not write something like: if(comboBoxValue="Description") Sorry from the comments I see I have not made it clear. I know I could do that through each properties but that would be ackward for So that "graphically" works but the observable collection is not back-updated with the command obcCfgPartPrograms = (ObservableCollection ) dtgFeatures.ItemsSource In our example we can change the string "pcacd" with "AAA" ObcCfgPartPrograms = (ObservableCollection ) dtgFeatures.ItemsSource ((TextBlock)content).Text = str.Replace(tbxSrc.Text, tbxDest.Text) The variable iii indicates the current row DataGridRow row = (DataGridRow)(iii) So what I do at first is to find out the index of the column (in our case Description index=2 starting from 0) and then operate the substitutions with the code below. bind the ItemsSource of my DataGrid to GridColumns. I need to do a string replace on a column chosen by the user at the runtime through a combobox. My approach so far has been this: create an ObservableCollection (lets name it GridColumns) property on my ViewModel containing each ObservableCollections I need.They have a large number of columns/properties I have to operate on. I have a datagrid linked with an observable collection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |