です。 あなたは変換ロジックを記述しますIValueConverter
を実装するクラスを作成することができ最初の必要性:
public class AlignmentConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if ((bool)value)
return Windows.UI.Xaml.HorizontalAlignment.Center;
return Windows.UI.Xaml.HorizontalAlignment.Left;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
あなたはおそらくあなたが今までにはない性質にこれをバインドする場合のビットより良いエラーを処理する必要があります*ブール
リソースとしてコンバータを宣言...あなたはページ
xmlns:converters="using:*yournamespace*"
の上部にあなたのcoverters名前空間をインポートする必要があり、これを使用するには:
<converters:AlignmentConverter x:Key="HorizontalAlignmentConverter"/>
...とあなたの結合
<Image Source="{Binding Thing.Url}" Stretch="UniformToFill" HorizontalAlignment="{Binding Thing.OtherProperty, Converter={StaticResource HorizontalAlignmentConverter}"/>
にパラメータとしてそれを使用します