Reputation: 900
I have a data grids within two tabs. so when second tab click it should open a filter window (not a <popup>
, its a <window>
) . I am doing it as follows.
if (tabControl1.SelectedIndex == 1) {
DashboardFilterView filterWindow = new DashboardFilterView();
filterWindow.ShowDialog(); }
When I click the close button of window it is closed.
Question :
After closing popup window, if I click on row of datagrid which is in my current tab, again popup window is displayed.
How can I prevent this from happening more than once?
Upvotes: 1
Views: 343
Reputation: 900
Since tabControl1_SelectionChanged
event is firing for even grid row click, I added a check to confirm whether this event occurs from tab.
e.OriginalSource is TabControl
solved the problem.
private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.OriginalSource is TabControl)
{
if (tabControl1.SelectedIndex == 0)
{
// Do something
}
else if (tabControl1.SelectedIndex == 1)
{
DashboardFilterView filterWindow = new DashboardFilterView();
filterWindow.ShowDialog();
}
}
}
Upvotes: 2