我有一个像这样的ListView:
<ListView x:Name="ArtistsList"
ItemsSource="{Binding Source={StaticResource ArtistsCVS}}"
SelectionMode="None"
ItemContainerStyle="{StaticResource ListViewContainerStrecher}"
IsItemClickEnabled="True"
ItemClick="ArtistsList_ItemClick">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:DAPP">
<Grid AutomationProperties.Name="{Binding artist}"
AutomationProperties.HelpText="Navigate to artist info page.">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
MaxWidth="60"
Source="{Binding thumb}"
HorizontalAlignment="Center"/>
<Grid Grid.Column="1" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding artist}"/>
</Grid>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
当我尝试使用讲述人时,它会读取艺术家名称,但它不会阅读帮助文本。另外,我想知道是否可以将两个值绑定到AutomationProperties.Name?
例如,我有一个ArtistName和一个SongName然后例如使用AutomationProperties.Name = "{Binding ArtistName};{Binding songName}"
然后它读取像艺术家(小暂停)SongName。
答案 0 :(得分:1)
当我尝试使用讲述人时,它会读取艺术家名称,但它不会阅读帮助文本。
在ListView
内设置AutomationProperties.HelpText attached property在这里不起作用。要解决此问题,我们可以使用自定义ListView和覆盖PrepareContainerForItemOverride方法来设置自动化属性。这也是为public class MyList : ListView
{
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
base.PrepareContainerForItemOverride(element, item);
FrameworkElement source = element as FrameworkElement;
source.SetBinding(AutomationProperties.NameProperty, new Binding
{
Path = new PropertyPath("Content.artist"),
RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self }
});
AutomationProperties.SetHelpText(source, "Navigate to artist info page.");
}
}
中的项添加辅助功能支持的推荐方法。
例如:
MyList
然后,您可以使用ListView
代替AutomationProperties.Name
,而无需再在AutomationProperties.HelpText
中设置Grid
和ArtistName
。有关详细信息,请参阅XAML accessibility sample。
我想知道是否可以将两个值绑定到AutomationProperties.Name?
UWP没有开箱即用的多重绑定支持。但是如果songName
和public class AutomationPropertiesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
//Suppose ArtistName and songName are the properties of Song class
var song = (Song)value;
return $"{song?.ArtistName} - {song?.songName}";
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
来自一个模型或视图模型,那么我们可以使用转换器来实现这一点:
public class MyList : ListView
{
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
base.PrepareContainerForItemOverride(element, item);
FrameworkElement source = element as FrameworkElement;
//Suppose Song class is the DataType of the DataTemplate
source.SetBinding(AutomationProperties.NameProperty, new Binding
{
Path = new PropertyPath("Content"),
RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self },
Converter = new AutomationPropertiesConverter()
});
AutomationProperties.SetHelpText(source, "Navigate to artist info page.");
}
}
使用转换器,如:
cd C:\folder
setlocal enabledelayedexpansion
SET /A COUNT=0
for %%a in (*.jpg) do (
SET /A COUNT+=1
ECHO !COUNT!
set f=%%a
IF !COUNT! GTR 9 (
set f=!f:^00 (=!
) ELSE (
set f=!f:^0 (=!
)
set f=!f:^)=!
ren "%%a" "!f!"
)
pause