title: Screenreader WPF Groupstyles
body: <p>I am trying to set the <code>AutomationProperties.Name</code> property for controls in a <code>GroupStyle</code> control template and it seems to produce nothing. I have it set on the <code>Expander</code> in my template but it says nothing even when I just put in some text without binding. I also tried putting a setter on the <code>GroupItem</code> and that also didn't work. I'm at a bit of a loss. I was hoping the property on the group item would solve it.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          x:Class="WpfApplication8.MainWindow"
          x:Name="win"
          Title="MainWindow"
          Width="640"
          Height="480"&gt;
  
    &lt;Grid x:Name="LayoutRoot"&gt;
      &lt;ListBox x:Name="lstbx"
               Margin="71,45,99,78"
               ItemsSource="{Binding ElementName=win,
                                         Path=Samples}"&gt;
        &lt;ListBox.GroupStyle&gt;
          &lt;GroupStyle&gt;
            &lt;GroupStyle.ContainerStyle&gt;
              &lt;Style TargetType="{x:Type GroupItem}"&gt;
                &lt;Setter Property="AutomationProperties.Name"
                        Value="this is a test" /&gt;
                &lt;Setter Property="KeyboardNavigation.TabNavigation"
                        Value="Cycle" /&gt;
                &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                    &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt;
                      &lt;Expander Name="templateLstBxExpander"
                                AutomationProperties.Name="test test test"
                                IsExpanded="True"&gt;
  
                        &lt;Expander.Header&gt;
                          &lt;StackPanel Orientation="Horizontal"&gt;
                            &lt;Label Name="templateLstBxExpanderHeader"
                                   Content="{Binding Path=Name}"
                                   FontWeight="Bold" /&gt;
                          &lt;/StackPanel&gt;
                        &lt;/Expander.Header&gt;
                        &lt;ItemsPresenter /&gt;
                      &lt;/Expander&gt;
                    &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
                &lt;/Setter&gt;
              &lt;/Style&gt;
            &lt;/GroupStyle.ContainerStyle&gt;
          &lt;/GroupStyle&gt;
        &lt;/ListBox.GroupStyle&gt;
      &lt;/ListBox&gt;
    &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>XAML.cs:</p>
  
  <pre><code>using System;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Shapes;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  namespace WpfApplication8
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  {
      public static readonly DependencyProperty sampleProperty = DependencyProperty.Register(
          "Samples", typeof(ObservableCollection&lt;sample&gt;), typeof(MainWindow), new PropertyMetadata(new ObservableCollection&lt;sample&gt;()));
  
      public ObservableCollection&lt;sample&gt; Samples
      {
          get
          {
              return (ObservableCollection&lt;sample&gt;)this.GetValue(sampleProperty);
          }
  
          set
          {
              this.SetValue(sampleProperty, value);
          }
      }      
  
      public MainWindow()
      {
          this.InitializeComponent();
  
           CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lstbx.ItemsSource);
          PropertyGroupDescription groupDescription = new PropertyGroupDescription("Location");
          view.GroupDescriptions.Add(groupDescription);      
          sample test = new sample();
          test.Location = "one";
          test.Name = "blah blah";
          Samples.Add(test);
          sample test2 = new sample();
          test2.Location = "two";
          test2.Name = "ya ya";
          Samples.Add(test2);
  
      }
  }
  }
  </code></pre>
  
  <p>sample.cs:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Shapes;
  
  namespace WpfApplication8
  {
  public class sample
  {
  
  
      public string Name { set; get; }
      public string Location{ set; get; }
  
  }
  </code></pre>