初めての Silverlight アプリを作成しています。2 つのラベルを持つ列を持つデータグリッドがあります。ラベルについては、IValueConverter を使用してデータを条件付きでフォーマットしています。
ラベルの「コンテンツ」は次のように設定されています。
Content="{Binding HomeScore, Converter={StaticResource fmtshs}}"
と
Content="{Binding AwayScore, Converter={StaticResource fmtshs}}"
私の IValueConverterのConvertメソッドは次のとおりです。
Public Function Convert(
ByVal value As Object,
ByVal targetType As System.Type,
ByVal parameter As Object,
ByVal culture As System.Globalization.CultureInfo) As Object
Implements System.Windows.Data.IValueConverter.Convert
Dim score As Long = value, other As Long = parameter
Return If(score < 0, "",
If(score - other > 5, (other + 5).ToString, score.ToString)
)
End Function
だから私がやりたいのは、HomeScore のコンバーターで、AwayScore を ConverterParameter に渡したいのです。AwayScore の場合、HomeScore をコンバーターに渡したいのです。どちらのスコアのコンバーターでも、書式設定のために他のスコアの値を知ることができる必要があります。
しかし、ConverterParameter を別のフィールドにバインドするための構文がわかりません。
私は次のことを試しました:
Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter=AwayScore}"
Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter={AwayScore}}"
Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter={Binding AwayScore}}"
しかし、それらのどれも機能していないようです。フィールド値を ConverterParameter に渡すにはどうすればよいですか?