mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-27 10:40:08 +00:00
Refactor ListBox in ProfilesView to use custom ItemContainerStyle
- Removed unused AccessibleMyChipListBoxItem style from UserControl.Resources. - Added a new ItemContainerStyle directly to the ListBox (lstGroup) with the following changes: - Set Focusable to False to prevent tab focus. - Set AutomationProperties.Name to Remarks for better accessibility. - Used a custom ControlTemplate with a RadioButton for item selection. This improves maintainability and ensures consistent accessibility behavior.
This commit is contained in:
parent
72b5a40b95
commit
a055108a53
1 changed files with 23 additions and 4 deletions
|
|
@ -18,9 +18,6 @@
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
|
<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
|
||||||
<conv:DelayColorConverter x:Key="DelayColorConverter" />
|
<conv:DelayColorConverter x:Key="DelayColorConverter" />
|
||||||
<Style x:Key="AccessibleMyChipListBoxItem" TargetType="ListBoxItem" BasedOn="{StaticResource MyChipListBoxItem}">
|
|
||||||
<Setter Property="AutomationProperties.Name" Value="{Binding Remarks}" />
|
|
||||||
</Style>
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
|
|
@ -29,7 +26,6 @@
|
||||||
x:Name="lstGroup"
|
x:Name="lstGroup"
|
||||||
MaxHeight="200"
|
MaxHeight="200"
|
||||||
FontSize="{DynamicResource StdFontSize}"
|
FontSize="{DynamicResource StdFontSize}"
|
||||||
ItemContainerStyle="{StaticResource AccessibleMyChipListBoxItem}"
|
|
||||||
Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}"
|
Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}"
|
||||||
AutomationProperties.Name="{x:Static resx:ResUI.menuSubscription}">
|
AutomationProperties.Name="{x:Static resx:ResUI.menuSubscription}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
|
|
@ -37,6 +33,29 @@
|
||||||
<TextBlock Text="{Binding Remarks}" />
|
<TextBlock Text="{Binding Remarks}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
<ListBox.ItemContainerStyle>
|
||||||
|
<Style TargetType="ListBoxItem" BasedOn="{StaticResource MyChipListBoxItem}">
|
||||||
|
<Setter Property="Focusable" Value="False" />
|
||||||
|
<Setter Property="AutomationProperties.Name" Value="{Binding Remarks}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ListBoxItem">
|
||||||
|
<RadioButton
|
||||||
|
IsChecked="{TemplateBinding IsSelected}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
AutomationProperties.Name="{Binding Remarks}">
|
||||||
|
<RadioButton.ContentTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock
|
||||||
|
AutomationProperties.Name="{Binding Remarks}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</RadioButton.ContentTemplate>
|
||||||
|
</RadioButton>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue