Greetings, people! My question is this: There is a wpf form
selectedObjectsDataGrid.ItemsSource = attributesManager.ObjectsInGrid;
Its source is a list of ObjectInGrid objects.
public class ObjectInGrid { private ObjType? type; public Guid Object { get; set; } public ObjType? Type { get { return type; } set { type = value; } } public ObjectInGrid(Guid obj) { Object = obj; } public enum ObjType { None = 0, Door = 1, Window = 2 } }
Combobox has three options (as in enum ObjType). Objects are sent to the datagrid as follows: the user selects one or more objects in the document by pressing, roughly speaking, an object is created
public void AddObjectToGrid(Guid id) { ObjectInGrid o = new ObjectInGrid(id); ObjectsInGrid.Add(o); }
Property Type, as well as Type column while empty. when the user has added all the objects, he selects one or several objects in the grid and selects the type in the combo box.
At the SelectionChanged event, the combo box finds by id the element in the list-source and fills the Type with the property.
I just started working with WPF, but I suppose that there is an opportunity to somehow “tie up” a type column and combo box in a normal way, and not like mine.
I don't like my approach:
- The SelectionChanged event is triggered when the selected item changes, but if I select another object and I need to set the same type for it as in the past, it will not be generated.
- I would like to do everything at a higher level. She searched for Google, but did not find anything concrete for this task.
Type
shown in the combo box? - VladD