c# wpf automation screen-readers

c# - Lectores de pantalla WPF Groupstyles



automation screen-readers (3)

El problema es realmente acerca de cómo se supone que el lector de pantalla alcanza el valor. Los elementos de grupo son accesibles desde el cursor a través de MSAA, pero no a través de UIA. UIA es la API principal que se utiliza para la accesibilidad en WPF.

El problema central con UIA y WPF es cuando intenta leer los controles que se encuentran con el cursor (otras formas son el enfoque y el cursor), generalmente devuelve la ventana principal.

Como desarrollador de un lector de pantalla, la mejor manera de lidiar con esto es utilizar MSAA y UIA. Si UIA no devuelve nada de valor, recurra al uso de MSAA.

Estoy tratando de establecer la propiedad AutomationProperties.Name para los controles en una plantilla de control GroupStyle y parece que no produce nada. Lo tengo configurado en el Expander en mi plantilla, pero no dice nada, incluso cuando solo puse un texto sin encuadernación. También intenté poner un setter en el GroupItem y tampoco funcionó. Estoy en una pequeña pérdida. Esperaba que la propiedad en el artículo del grupo la resolviera.

XAML:

<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"> <Grid x:Name="LayoutRoot"> <ListBox x:Name="lstbx" Margin="71,45,99,78" ItemsSource="{Binding ElementName=win, Path=Samples}"> <ListBox.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="AutomationProperties.Name" Value="this is a test" /> <Setter Property="KeyboardNavigation.TabNavigation" Value="Cycle" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <Expander Name="templateLstBxExpander" AutomationProperties.Name="test test test" IsExpanded="True"> <Expander.Header> <StackPanel Orientation="Horizontal"> <Label Name="templateLstBxExpanderHeader" Content="{Binding Path=Name}" FontWeight="Bold" /> </StackPanel> </Expander.Header> <ItemsPresenter /> </Expander> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </ListBox.GroupStyle> </ListBox> </Grid> </Window>

XAML.cs:

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 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public static readonly DependencyProperty sampleProperty = DependencyProperty.Register( "Samples", typeof(ObservableCollection<sample>), typeof(MainWindow), new PropertyMetadata(new ObservableCollection<sample>())); public ObservableCollection<sample> Samples { get { return (ObservableCollection<sample>)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); } } }

muestra.cs:

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; } }


Intente configurar AutomationProperties.HelpText junto con Name .


Puedes usar DisplayMemberPath="Name" :

<ListBox x:Name="lstbx" Margin="71,45,99,78" ItemsSource="{Binding ElementName=win, Path=Samples}" DisplayMemberPath="Name" >

O puedes usar .ToString() :

public class sample { public string Name { set; get; } public string Location { set; get; } public override string ToString() { return Name; } }