正如您在下面的代码中看到的,我从Microsoft Sample
获得<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 =&#34; itemGridView&#34;
AutomationProperties.Name =&#34;分组项目&#34;
我想知道xaml中上述行的作用是什么。
答案 0 :(得分:8)
来自Microsoft UI自动化概述
...它使辅助技术产品(如屏幕阅读器)能够向最终用户提供有关UI的信息,并通过标准输入以外的方式操作UI ...
http://msdn.microsoft.com/en-us/library/windows/desktop/ee684009.aspx
编辑:
例如,在Visual Studio中,如果您创建新的Windows应用商店网格应用,请查看GroupedItemsPage.xaml。您将看到一些已设置AutomationProperties.Name的位置。
现在打开Windows 8 Charms栏并搜索“讲述人”,然后运行结果中出现的讲述人应用程序。你会听到一个男人开始在屏幕上看东西。
如果你回到Visual Studio并运行你创建的新网格应用程序,讲述人将阅读网格应用程序中的各种内容,其中一些将是xaml中定义的AutomationProperties.Names。
尝试更改AutomationProperties.Name以了解其工作原理。
答案 1 :(得分:0)
我对此做了一些研究,我想用它在Style-ControlTemplate中设置可见性。
但是,此页面说明了如何使用AutomationProperties: http://msdn.microsoft.com/en-us/library/ff400332%28v=vs.95%29.aspx
例如,考虑一下这个xaml ::
<Button AutomationProperties.Name="Back"
Content="{Binding Title}"
Style="{StaticResource TextButtonStyle}" />
查看它使用的样式:{StaticResource TextButtonStyle}
,这对应于您的一个ResourceDictionaries中的样式。
<Style x:Key="TextButtonStyle" TargetType="ButtonBase">
在此样式中,可以使用AutomationProperties:
<TextBlock x:Name="TextLabel" Text="{TemplateBinding AutomationProperties.Name}" />
基本上,您可以使用AutomationProperties来填充具有特定属性的模板。