我在 WPF 数据网格上单击鼠标右键时使用 ShowDialog() 打开一个无边框窗口。目的是让用户有机会将选定的项目添加到列表中。当对话框窗口打开 DataGrid 中的选定项目时,松开选定的“视觉效果”(在本例中为默认的蓝色突出显示),直到对话框关闭。我该如何解决这个问题,以便用户仍然可以直观地了解他们选择的内容。
打开对话框的代码 =
private void MusicLibrary_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
Point mousePoint = this.PointToScreen(Mouse.GetPosition(this));
PlayListRClick option = new PlayListRClick();
option.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
option.Height = 150;
option.Width = 100;
option.Left = mousePoint.X;
option.Top = mousePoint.Y;
option.ShowDialog();
//Get the selected option and add itmes to playlist as needed
switch (option.choice)
{
case RightClickChoice.AddToPlayList:
IList Items = MusicLibrary.SelectedItems;
List<MyAlbum> albums = Items.Cast<MyAlbum>().ToList();
foreach (MyAlbum a in albums)
{
PlayListOb.Add(a);
}
break;
}
}