2017-11-08 3 views
1

私はUWPアプリケーションを開発しています。あるシナリオでは、ListViewにドラッグアンドドロップ機能を追加する必要があります。 ItemTemplateが定義されている場合、DragItemsStartingイベントはトリガを取得しません。ItemsViewが定義されているときListViewをドラッグ

境界線を選択してListViewItemをドラッグ操作するとうまくいきますが、項目をドラッグすると機能しません。ここで

Here is the Image for drag operation on items border:

XAMLコードは次のとおりです。

<ListView Grid.Row="3" 
       ScrollViewer.IsScrollInertiaEnabled="True" 
       ScrollViewer.VerticalScrollBarVisibility="Auto" 
       ScrollViewer.VerticalScrollMode="Enabled" 
       CanDragItems="True" 
       CanReorderItems="True" 
       ReorderMode="Enabled" 
       AllowDrop="True" 
       SelectionMode="Single" 
       VerticalAlignment="Stretch" 
       HorizontalAlignment="Stretch" 
       DragItemsStarting="{x:Bind VM.DragItemsStarting, Mode=OneWay}" 
       DragOver="{x:Bind VM.DragOver, Mode=OneWay}" 
       Drop="{x:Bind VM.DragDrop, Mode=OneWay}" 
       ItemsSource="{x:Bind ItemSource, Mode=OneWay}"> 

    <ListView.ItemTemplate> 
      <DataTemplate x:DataType="model:Model"> 
       <Button HorizontalAlignment="Stretch" 
         HorizontalContentAlignment="Stretch" 
         Command="{Binding DataContext.PageCommand, ElementName=pageMain}"> 
        <Grid> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="*" /> 
          <RowDefinition Height="10" /> 
         </Grid.RowDefinitions> 
         <TextBlock Text="{x:Bind ShowName,Mode=OneWay}" 
            VerticalAlignment="Center" 
            HorizontalAlignment="Center" 
            Foreground="Black" 
            TextWrapping="WrapWholeWords" 
            Margin="3" /> 
         <ProgressBar Grid.Row="1" 
            Margin="0" 
            Value="25" 
            Height="8" 
            VerticalAlignment="Bottom" 
            Foreground="Green" /> 
        </Grid> 
       </Button> 
      </DataTemplate> 
     </ListView.ItemTemplate> 

は、私は完全なのListViewItemにドラッグ操作を行うことができます方法はありますか?

答えて

0

ButtonItemTemplateに直接入れないでください。アプリケーションにドラッグアンドドロップ機能がある場合は、Gridなどを使用してください。今ListItemにクリック機能を有効にする

TrueIsItemClickEnabledプロパティを設定し、ListViewItemClickイベントを使用します。

+0

ありがとうIpsit Gaur。問題は今解決されました。犯人はテンプレート内のボタンだった。 –

関連する問題