I Have a DataGrid and I'd like to open a context Menu on rightclick, and filter it in base of a property of the selected item.
The problem is that with "fileGrid_MouseRightButtonUp" the selected item isnot the one under the cursor, but the previeouly selected one.
So how can i select the item of the datagrid on rightclick?
Its WPF im talking about
The piece of code:
private void fileGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
if (fileGrid.SelectedItems.Count != 0)
{
if(fileGrid.SelectedItems.Count == 1 && !(fileGrid.SelectedItem as FileD).EsAudio)
{
cMenu.Items.Filter = item =>
{
var it = item as MenuItem;
return it.Header.ToString() != "ConvertToAudio";
};
}
else
{
cMenu.Items.Filter = item =>
{
return true;
};
}
}
}