UWP网格操作叠加

时间:2015-12-11 12:50:47

标签: grid uwp swipe-gesture

我在UWP Apps中遇到 Grid 重叠问题。 我有以下控件(没有 ColumnDefinitions 以便更好地查看):

Control

    $arr = array
    (
        [0] => stdClass Object
            (
                [type] => ab_micro_list
                [title] => Testing List
                [user_id] => 70318
                [micro_list_id] => 390
            )

        [1] => stdClass Object
            (
                [type] => ab_micro_list
                [title] => Testing List
                [user_id] => 70319
                [micro_list_id] => 390
            )

    );
    $finalArr = array();
    foreach($arr as $key=>$value){

       $finalArr[$value->title]['users'][] = $value->user_id;

    }

哪个好看。我可以点击三个区域中的一个,它会触发 Grid 中的 Tapped 事件。现在我想更进一步,还包括一个"滑动手势"。

所以我把 Grid 置于其上:

<Grid>
  <Grid Grid.Column="1" Background="Transparent" Tapped="doneGrid_Tapped">
    <TextBlock Text="fertig" Foreground="Lime" HorizontalAlignment="Center" VerticalAlignment="Center" />
  </Grid>

  <Grid Grid.Column="3" Background="Transparent" Tapped="allGrid_Tapped">
    <TextBlock Text="alle" Foreground="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" />
  </Grid>

  <Grid Grid.Column="5" Background="Transparent" Tapped="undoneGrid_Tapped">
    <TextBlock Text="ausstehend" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center" />
  </Grid>
</Grid>

现在我可以向左和向右滑动,但我的 Tapping 不再有效,只能滑动。

如何点击和滑动两者都有效?

1 个答案:

答案 0 :(得分:1)

我测试了它,当你在其他网格之后使用Grid使用Grid.ColumnSpan = "7"时,你实际上将Grid置于其他网格之上,所以你只能得到焦点这个Grid。当你在其他网格之前使用Grid使用Grid.ColumnSpan = "7"时,它位于其他网格的较低层,可以在gird3,grid5和grid7之外进行操作,这些3个网格可以被点击,但是当你想从grid3,5,7开始操作时,它无法工作。为了实现您的期望,您还需要添加任何Gird使用Grid.ColumnSpan = "7",您只需要像这样操作:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid ManipulationMode="TranslateX" ManipulationStarted="manipulationStarted" ManipulationCompleted="manipulationCompeleted">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="1" Background="Transparent" Tapped="doneGrid_Tapped">
            <TextBlock Text="fertig" Foreground="Lime" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Grid>

        <Grid Grid.Column="3" Background="Transparent" Tapped="allGrid_Tapped">
            <TextBlock Text="alle" Foreground="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Grid>

        <Grid Grid.Column="5" Background="Transparent" Tapped="undoneGrid_Tapped">
            <TextBlock Text="ausstehend" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center" />
        </Grid>

        <!--<Grid Grid.ColumnSpan="7" Background="Transparent" ManipulationMode="TranslateX" ManipulationStarted="manipulationStarted" ManipulationCompleted="manipulationCompeleted" />-->

    </Grid>
</Grid>

现在您可以点按它们或翻转Grid。 希望这能帮到你。