开发者

Can I use a DataTemplate for toolbar buttons and still make the name meaningful?

开发者 https://www.devze.com 2023-04-13 08:00 出处:网络
I have a Toolbar whose ItemSource is a collection of toolbarItems which contain the bitmap text and other info for the button and the xaml includes a DataTemplate to bind the data to the button.

I have a Toolbar whose ItemSource is a collection of toolbarItems which contain the bitmap text and other info for the button and the xaml includes a DataTemplate to bind the data to the button.

Our app now needs to become 508 compliant and when I run the Accessible Event Watcher it is listing all the toolbar button names as "Unknown".

Can someone tell me how to provide a meaningful name to the buttons?

Here's the portion of xaml applying to this issue:

<ToolBar.ItemTemplate>
    <DataTemplate DataType="{x:Type src:toolBarItem}">
          <DataTemplate.Resources>
           <src:toolBarItemConverter x:Key="buttonConverter" />
           <src:booleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
              <src:toolBarButtonFormatConverter x:Key="toolBarFormatDisplayConverter" />
              <src:stringToVisibilityConverter x:Key="stringToVisibilityDisplayConverter" />
    </DataTemplate.Resources>

    <StackPanel Orientation="Horizontal">

        <Border Style="{StaticResource SeparatorStyle}" Visibility="{Binding menuSeparator, Converter={StaticResource boolToVisibilityConverter}}"/>

        <Button x:Name="listButton" Height="{Binding menuHeight, Mode=OneWay}" Width="{Binding menuWidth}" VerticalAlignment="Top" HorizontalAlignment="Center" Visibility="{Binding isActiveButton, Converter={StaticResource boolToVisibilityConverter}}" Tag="{Binding}" 
      ToolTip="{Binding menuTooltip}"  IsEnabled="{Binding isEnabled}"  >
             <UniformGrid VerticalAlignment="Center" HorizontalAlignment="Center" Rows="{Binding menuText,Converter={StaticResource toolBarFormatDisplayConverter}}" >
     <!-- button image -->
     <Image Grid.Row="0"  HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding menuImage, Converter={StaticResource buttonConverter}}"/>
     <!-- button name -->
              <Viewbox StretchDirection="DownOnly" HorizontalAlignment="Center" VerticalAlignment="Bottom" Visibility="{Binding menuText, Converter={StaticResource stringToVisibilityDisplayConverter}}" >
               <TextBlock x:Name="buttonName" FontFamily="Segoe UI" Width="{Binding menuWidth}"  FontSize="12" Grid.Row="1" TextAlignment="Center" TextWrapping="Wrap" HorizontalAli开发者_如何学Pythongnment="Center" VerticalAlignment="Bottom" Text="{Binding menuText}" Foreground="Black" />
     </Viewbox>
    </UniformGrid>
      <!-- </StackPanel> -->
      </Button>          
          </StackPanel>
        </DataTemplate>
   </ToolBar.ItemTemplate>

Thanks,

Ron


OK we figured this out. Need to simply bind your names to the AutomationProperties.Name

<Button x:Name="listButton" AutomationProperties.Name="{Binding menuText}" 
Height="{Binding menuHeight, Mode=OneWay}" Width="{Binding menuWidth}"  
VerticalAlignment="Top" HorizontalAlignment="Center" 
Visibility="{Binding isActiveButton,  
Converter={StaticResource boolToVisibilityConverter}}" 
Tag="{Binding}" ToolTip="{Binding  menuTooltip}"  IsEnabled="{Binding isEnabled}"  >
0

精彩评论

暂无评论...
验证码 换一张
取 消