开发者

How to handle single click in the WPF grid

Currently i am using the following code to handle the double click event on a grid. Now the requirements has changed so that instead of double click a single click is only required to select an item. What is the event to detect single click?

<EventSetter Event="MouseDoubleClick" Handler="row_MouseDoubleClick"/>

I tried following for trapping single click without success.

<EventSetter Event="MouseLeftButtonDown" Handler="row_MouseDoubleClick"/>

I cannot see the program breaking at the breakpoint when

MouseLeftButtonDown

is implemented

Plea开发者_如何学Gose advice,

Regards,

Joe.


Buy a ListView now, get selection for free!

<ListView>
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <Grid IsItemsHost="True">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
            </Grid>
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
    <ListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="Grid.Column" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.(Grid.Column)}"/>
            <Setter Property="Grid.Row" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.(Grid.Row)}"/>
        </Style>
    </ListView.ItemContainerStyle>
    <ListView.ItemsSource>
        <x:Array Type="{x:Type sys:Object}">
            <TextBlock Grid.Column="0" Grid.Row="0" Text="Lorem"/>
            <TextBlock Grid.Column="1" Grid.Row="0" Text="Ipsum"/>
            <TextBlock Grid.Column="0" Grid.Row="1" Text="Dolor"/>
            <TextBlock Grid.Column="1" Grid.Row="1" Text="Sit"/>
        </x:Array>
    </ListView.ItemsSource>
</ListView>


How about,

 <EventSetter Event="MouseUp" Handler="row_MouseClick"/>

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜