正如你在下面的代码中看到的,我从微软示例中得到

<SemanticZoom.ZoomedOutView>
    <tiles:VariableTileControl  x:Name="SemanticItemGridView"
                                AutomationProperties.AutomationId="itemGridView"
                                AutomationProperties.Name="Grouped Items"
                                Padding="80,87,10,0"
                                ItemsSource="{Binding Source={StaticResource SemanticgroupedItemsViewSource}}"
                                ItemTemplateSelector="{StaticResource SemanticMyTemplates}"
                                SelectionMode="None"
                                IsSwipeEnabled="false"
                                IsItemClickEnabled="True"
                                ItemClick="ItemView_ItemClick"
                                Margin="0,0,0,-13"
                                HorizontalAlignment="Left"
                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                ItemContainerStyle="{StaticResource SemanticGridViewItemStyle}">
        <tiles:VariableTileControl.ItemsPanel>
            <ItemsPanelTemplate>
                <VariableSizedWrapGrid Margin="0,0,10,0"/>
            </ItemsPanelTemplate>
        </tiles:VariableTileControl.ItemsPanel>
        <tiles:VariableTileControl.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Margin="1,0,0,6" Orientation="Horizontal" MinWidth="280">
                            <Button AutomationProperties.Name="Group Title"
                                    Content="{Binding Title}"
                                    Click="Header_Click"
                                    Style="{StaticResource TextButtonStyle}" Foreground="White" FontSize="28" Background="#FFD71921" FontWeight="Light"/>
                            <TextBlock x:Name="tbk" Text="TM" VerticalAlignment="Top" Visibility="{Binding Tm}"/>
                            <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="28" FontWeight="Light" Text="("/>
                            <TextBlock x:Name="txtNo" TextWrapping="Wrap" Text="{Binding No}" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="28" FontWeight="Light"/>
                            <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" FontFamily="Segoe UI" FontSize="28" FontWeight="Light" Text=")"/>
                            <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="10,0,0,10" Style="{StaticResource GroupHeaderTextStyle}" Foreground="#FF9F9F9F"/>
                            <TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="0,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubTl}"/>
                            <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="0,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubT2}"/>
                        </StackPanel>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
                <GroupStyle.Panel>
                    <ItemsPanelTemplate>
                        <VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" Orientation="Vertical" Margin="0,0,10,0"/>
                    </ItemsPanelTemplate>
                </GroupStyle.Panel>
            </GroupStyle>
        </tiles:VariableTileControl.GroupStyle>
    </tiles:VariableTileControl>
</SemanticZoom.ZoomedOutView>

<SemanticZoom.ZoomedInView>
    <GridView   x:Name="itemGridView"
                AutomationProperties.AutomationId="itemGridView"
                AutomationProperties.Name="Grouped Items"
                Padding="116,110,40,10"
                ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
                ItemTemplateSelector="{StaticResource LivTemplates}"
                SelectionMode="None"
                IsSwipeEnabled="false"
                IsItemClickEnabled="True"
                ItemClick="ItemView_ItemClick"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal" Margin="0,0,80,0"/>
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
        <GridView.GroupStyle>
            <GroupStyle ContainerStyle="{StaticResource HubPageMoreGroupItemStyle}">
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Margin="1,0,0,6" Orientation="Horizontal">
                            <Button AutomationProperties.Name="Group Title"
                                    Content="{Binding name}"
                                    Click="Header_Click"
                                    Style="{StaticResource TextButtonStyle}"
                                    Foreground="White" FontSize="32"
                                    Background="#FFD71921" FontWeight="Light"/>
                            <TextBlock x:Name="tbk" Text="TM" VerticalAlignment="Top" Visibility="{Binding Tm}"/>
                            <TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="10,0,0,10" Style="{StaticResource GroupHeaderTextStyle}" Foreground="#FF9F9F9F"/>
                            <TextBlock x:Name="txtVideo" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="0,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubTl}"/>
                            <TextBlock x:Name="txtPicture" HorizontalAlignment="Right" TextWrapping="Wrap" Text="{Binding Sub2}" VerticalAlignment="Bottom" Foreground="#FFC4261D" Margin="0,21,0,0" FontFamily="Segoe UI" FontSize="16" Visibility="{Binding SubT2}"/>
                        </StackPanel>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
                <GroupStyle.Panel>
                    <ItemsPanelTemplate>
                        <VariableSizedWrapGrid ItemHeight="5" ItemWidth="5" Orientation="Vertical" Margin="0,0,133,0"/>
                    </ItemsPanelTemplate>
                </GroupStyle.Panel>
            </GroupStyle>
        </GridView.GroupStyle>
    </GridView>
</SemanticZoom.ZoomedInView>

在上面的代码中,我只对如下所示的一行感兴趣
AutomationProperties.AutomationId="itemGridView"

AutomationProperties.Name="分组项目"

我想知道上面提到的行在 xaml 中的作用是什么。

最佳答案

来自 Microsoft UI 自动化概述



http://msdn.microsoft.com/en-us/library/windows/desktop/ee684009.aspx

编辑:

例如,在 Visual Studio 中,如果您创建新的 Windows 应用商店网格应用,请查看 GroupedItemsPage.xaml。您会看到一些设置了 AutomationProperties.Name 的地方。

现在打开 Windows 8 Charms Bar 并搜索“Narrator”,然后运行结果中出现的 Narrator 应用程序。你会听到一个男人开始在屏幕上读东西。

如果您返回到 Visual Studio 并运行您创建的新网格应用程序,讲述人将读取网格应用程序中的各种内容,其中一些将是在 xaml 中定义的 AutomationProperties.Names。

尝试更改 AutomationProperties.Name 以了解其工作原理。

关于xaml - Windows 8 Metro::什么是 AutomationProperties.AutomationId 和 AutomationProperties.Name,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16420317/

10-11 14:02