我有这样的 XAML。基本上它连接了多个绑定到不同属性的字符串。假设出于某种原因,我不想在 VM 上公开另一个属性以将其作为单个属性。
是否有任何其他 XAML 绑定方法可以使其更紧凑?
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Text="Added by " FontSize="10" Foreground="#2C2C2C" />
<TextBlock Text="{Binding Document.MEMUser.UserName}" Foreground="#2C2C2C" FontSize="10" />
<TextBlock Text=" on " FontSize="10" Foreground="#2C2C2C"/>
<TextBlock Text="{Binding CreatedOn, Converter={StaticResource DateTimeToStringConverter}}" Foreground="#2C2C2C" FontSize="10" />
<!--BIND COMMANDS TO PARENT ViewModel to process operations-->
<Button Content="Delete" Command="{Binding DataContext.DeleteCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
<Button Content="Download" Command="{Binding DataContext.DownloadCommand, ElementName=LayoutRoot}" CommandParameter="{Binding}" />
</StackPanel>