Ok this might be simple or just not possible. Probably it's something that is frowned upon.
Let's say I have a combobox and a button beside it. I choose a item from the combobox and press the button.
In my button handler I guess I'm supposed to fetch combobox.selectedValue to get the item ( is there a better way).
Let's say I don't have access to the combobox where the eventhandler is could I bind the button somehow to the selectedvalue so I would have access to it through the button?
private void addItemClick(object sender, RoutedEventArgs e)
{
collection.add( classFactory.NewInstanceOfId( (sender as button).DataContainer);
}
Is this something you shouldn't do? Does Combobox perhaps have some inherit event to do this (I want a button to confirm). If I include the button inside the ComboBox somehow I guess I could use Button.DataContext ?