怎么让listview的选项的双击事件暂时失效

shijunti19 2009-11-04 09:10:03
我放了个按钮,当按下去我要让listview的选项的双击事件暂时失效!
我要代码!
...全文
43 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yishuiyixu 2009-11-09
  • 打赏
  • 举报
回复
<Window x:Class="WpfApplication3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="400" Background="White">
<Grid x:Name="grid" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<ListView Grid.Column="0" x:Name="List" MouseDoubleClick="List_MouseDoubleClick">
<ListViewItem Content="First"/>
</ListView>
<Button Content="Disable" Grid.Column="1" Click="Button_Click" x:Name="button" Width="60" Height="30" ></Button>

</Grid>
</Window>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication3
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
private bool IsDisable = false;

public Window1()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
if(IsDisable)
{
IsDisable = false;
this.button.Content = "Disable";
}
else
{
IsDisable = true;
this.button.Content = "Enable";
}
}

private void List_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (IsDisable)
{
e.Handled = true;
}
else
{
this.grid.Background = Brushes.AliceBlue;
}
}
}
}

功能描述:
点击"Disable"的Button之前, 双击ListView的话, Button那半边的背景会变成浅蓝色.
如果点击"Disable"的Button,双击ListView, Button那半边的背景不变.

17,740

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET Framework
社区管理员
  • .NET Framework社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧