【发布时间】:2013-12-29 19:48:31
【问题描述】:
我有一个如下代码中提到的文本块:
<TextBlock Grid.Row=........
.................
Grid.RowSpan="{Binding RowSp}"
HorizontalAlignment="Left" />
现在我想检查是否RowSpan > 1 然后我想在文本末尾添加一个空格和一个冒号。我认为(未尝试)我已经使用触发器和转换器得到它如下代码中所述:
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="{Binding RowSp,
Converter={StaticResource colonAlignmentConverter}}"
Value="True" >
<Setter Property="Text"
Value="{Binding Txt,
Converter=ColonAlignmentConverter}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
public class ColonAlignmentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (int)value > 1;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
现在问题来了:
如果RowSpan = 1 那么我想在同一个 Grid.Row 和 Grid.Column 中添加冒号(:) 但我想要它right aligned。我怎样才能做到这一点?
如果可能的话,我可以使用另一个文本块作为冒号。
【问题讨论】: