ToolBarでToggleButtonsを使用していますが、UI Automationテストで取得して使用したいのですが、これらのボタンのAutomationElement.Currentをチェックすると、WPFのAutomationElement ToggleButton - ClassNameボタンを持っています
<ToolBar ItemsSource="{Binding}"/>
私はDataTemplateのを持っているのItemsSourceでの型のために:
<DataTemplate DataType="{x:Type myViewModelType}">
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource MyToolBarElementTemplate}">
<ContentPresenter.Resources>
<Style TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource ThisStyleSetsWidthAndHeight}"/>
</ContentPresenter.Resources>
</ContentPresenter>
</DataTemplate>
私はトグルボタン
は、XAMLがstarightforwardされていないので、私はそれをここに言及期待します
スタイルは次のように定義されています
<Style TargetType="{x:Type ButtonBase}" x:Key="ThisStyleSetsWidthAndHeight">
<Setter Property="styles:AttachedProperties.ContentWidth" Value="32"/>
<Setter Property="styles:AttachedProperties.ContentHeight" Value="32"/>
</Style>
とコンテンツテンプレートは、次のようになります。
<DataTemplate x:Key="MyToolBarElementTemplate" DataType="{x:Type myViewModelType}">
<ToggleButton x:Name="AutomationIdThatIGetOk">
...
</ToggleButton>
</DataTemplate>
私はそれがすべてのこれらのテンプレートとしなければならないと思い、オートメーションフレームワークに少し新しいですスタイルを使用できますが、このToggleButton用に作成された適切なAutomationPeerインスタンスを取得する方法はありますか?
私は、HelpTextを使ってプロッパーボタンを識別し、それらのTogglePatternを使ってやりたいことをする – Myar