【发布时间】:2014-01-12 08:31:50
【问题描述】:
我正在使用列表框,当您单击其上的项目时,您会看到蓝线标记在列表框的值上,我想禁用它,您无法标记列表框的值并且 复制粘贴
我尝试了 IsSelected="False" 但没有成功...
<ListBox x:Name="seus" IsSelected="False" Height="115" Width="150" ItemsSource="{Binding Use}" SelectionChanged="listbox_SelectionChanged" AllowDrop="True" PreviewDrop="ListBox_PreviewDrop" />
这是列表框的事件
private void listbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (sender is ListBox)
{
var listBox = sender as ListBox;
if (e.AddedItems.Count == 1)
{
if (listBox.SelectedItem != null)
{
var mySelectedItem = listBox.SelectedItem as User;
if (mySelectedItem != null)
{
DragDrop.DoDragDrop(listBox, mySelectedItem.Name, DragDropEffects.Copy | DragDropEffects.Move);
}
}
}
}
else
return;
}
【问题讨论】:
-
就在字里行间,否则返回;在这种情况下是一个冗余的控制流跳转语句。你可以简单地删除它。