[英]uwp-community-toolkit : GridView - Pb selection on usercontrol with CanDrag and DragStarting on MasterDetail
我使用uwp社區模板制作一個單頁應用程序,添加帶有templateitem的gridview並激活多選。 在那里,我在項目模板上添加了“ CanDrag”和事件“ DragStarting”。
結果是:當堆棧面板(藍色)或圖像包含在itemtemplate中時,沒有選擇。
任何想法 ?
我的代碼,只需將網格添加到sampleorder上的默認主視圖插件即可。
<Page.Resources>
<DataTemplate x:Key="detTemplate" x:DataType="model:SampleOrder">
<StackPanel Height="64" Orientation="Horizontal" CanDrag="True" DragStarting="Items_DragStarting" >
<FontIcon Tag="{x:Bind HashIdentIcon}" FontSize="40" Glyph="{x:Bind SymbolAsChar}" VerticalAlignment="Center" />
<StackPanel Margin="12,0,0,0" VerticalAlignment="Center" Width="150" Background="Aqua">
<TextBlock Text="{x:Bind Company}" Tag="{x:Bind HashIdentTitle}" Style="{ThemeResource ListTitleStyle}" />
<TextBlock Text="{x:Bind Status}" Style="{StaticResource ListSubTitleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</Page.Resources>
<Grid
x:Name="ContentArea"
Margin="{StaticResource MediumLeftRightMargin}">
<Grid.RowDefinitions>
<RowDefinition x:Name="TitleRow" Height="48"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock
x:Name="TitlePage"
x:Uid="Main_Title"
Style="{StaticResource PageTitleStyle}" />
<Grid
Grid.Row="1"
Background="{ThemeResource SystemControlPageBackgroundChromeLowBrush}">
<GridView x:Name="Lines" Background="{ThemeResource AppBarBackgroundThemeBrush}" SelectionMode="Multiple" IsMultiSelectCheckBoxEnabled="False" MinHeight="150"
ItemsSource="{x:Bind ViewModel.SampleItems, Mode=OneWay}"
ItemTemplate="{StaticResource detTemplate}" >
</GridView>
</Grid>
<!-- Adaptive triggers -->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WindowStates">
<VisualState x:Name="WideState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="640"/>
</VisualState.StateTriggers>
</VisualState>
<VisualState x:Name="NarrowState">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="TitlePage.Margin" cu:Value="48,0,12,7" fcu:Value="0,0,12,7"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
不要將拖動內容放在模板上。 而是將其放在GridView上。
<GridView AllowDrop="True"
CanDragItems="True"
DragItemsStarting="OnDragItemsStarting"
DragOver="OnDragOver"/>
這里有一些資源可以幫助您:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.