I have a MVVM application with a MainWindowViewModel
connected to a MainWindow
view.
On the MainWindow
view I have a ComboBox
containing stock ticker symbols.
I have another viewmodel and view called AllStockQuoteViewModel
connected to AllStockQuoteView
which contains a list of stocks and their prices.
I want to be able to select an item from the ComboBox
and have the item in the AllStockQuoteView
selected and highlighted. On my MainWindowViewModel
I have saved the reference to the AllStockQuoteViewModel
and use it to call a method to find the stock ticker symbol in the ObservableCollection
bound to the AllStockQuoteView
, but haven't found a way to programmatically select the item on the AllStockQuoteView
.
I have a SelectedQuote
property on the AllStockQuoteViewModel
bound to the listview on the AllStockQuoteView
and I can select one of the items and my SelectedQuote
property is set fine. If I set this programmatically in my SelectQuote
method, it doesn't appear as if the item is selected in the view, although the item is passed back to the MainWindowViewModel
and I can use it to populate the textblocks on MainWindow
view.
I'd like to be able to show the item on the AllStockQuoteView
as being selected via highlighting as if the user selected it.
How can this be done?