简体   繁体   中英

C# - Listview Fullrowselect on UWP

I want do some things with my listview on my UWP project:

When a item of the listview is selected I want the entire row selected, also the subitems (cells) on the row should be not selectable.

与此类似


I was trying with Fullrowselect but seem is not longer availiable in uwp.

my current xaml is:

<ListView x:Name="ListView1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,164,0,0" BorderBrush="Black" BorderThickness="1" Background="WhiteSmoke" Visibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"  >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid Padding="0" Margin="0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="130" />
                            <ColumnDefinition Width="300" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40"/>
                        </Grid.RowDefinitions>
                        <TextBox x:Name="TextBox_Item" Grid.Column="0" Text="{Binding Path=Item}" TextWrapping="Wrap" BorderBrush="Black" BorderThickness="1.5" IsReadOnly="True" TextAlignment="Left"/>
                        <TextBox x:Name="TextBox_Name" Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="Wrap" BorderThickness="1.5" BorderBrush="Black" IsReadOnly="True" TextAlignment="Left"/>
                  </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Any help is appreciated.

There's a property called "IsHitTestVisible, try changing it to false on your textboxes.

    <ListView x:Name="ListView1" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,164,0,0" BorderBrush="Black" BorderThickness="1" Background="WhiteSmoke" Visibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"  >
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid Padding="0" Margin="0" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="130" />
                        <ColumnDefinition Width="300" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40"/>
                    </Grid.RowDefinitions>
                    <TextBox x:Name="TextBox_Item" Grid.Column="0" Text="{Binding Path=Item}" TextWrapping="Wrap" BorderBrush="Black" BorderThickness="1.5" IsReadOnly="True" TextAlignment="Left" IsHitTestVisible="False"/>
                    <TextBox x:Name="TextBox_Name" Grid.Column="1" Text="{Binding Path=Name}" TextWrapping="Wrap" BorderThickness="1.5" BorderBrush="Black" IsReadOnly="True" TextAlignment="Left" IsHitTestVisible="False"/>
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM