I have a static collection:
<CollectionViewSource Source="{Binding Source={x:Static Application.Current}, Path=MarketDataListeners}" x:Key="ficServerMarketDataView"></CollectionViewSource>
which is a collection of type MarketDataListener
.
I have a ListView which is bound to this collection and a ContentControl which is bound to the selected item of this ListView. In the ContentControl I have a button that launches a child window (in code behind).
What Im doing is keeping track of the selected item in the main window like this:
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
_selectedItem = ((sender as ListView).SelectedValue as MarketDataContainer);
}
and then when the button in the control control is clicked i execute:
private void ShowComponentsButton_Click(object sender, RoutedEventArgs e)
{
var detailsWindow = new ComponentWindow(_selectedItem);
var button = sender as Button;
if (button == null) return;
detailsWindow.Show();
}
This is the binding of the ContentControl:
<ContentControl Name="Detail" Content="{Binding Source={StaticResource ficServerMarketDataView}}"
ContentTemplate="{StaticResource detailsFicTemplate}" VerticalAlignment="Stretch" Foreground="Black" DockPanel.Dock="Bottom" />
Is it possible to remove the code tracking the selected item just launch the child window without a parameter? The child window's Title should be a property 'Name' on the currently selected MarketDataListener
. Ideally the child window would not update when the selected item changes.