2016-09-13 8 views
0

x:バインドを使用してデータをバインドすると、xamlでバインドされますが、同じコードがx:バインドの代わりにバインディングを使用して実行された場合は動作しません。なぜこれが起こるのですか?私はそれらの違いを読んだことは、ランタイムと他のコンパイル時とそのようなものだが、それはまったく助けにならないということです。誰かが実践的なレベルで私を助けることができますか?x:バインドとバインディングの違い

+2

は、あなたが見てきました[this](https://msdn.microsoft.com/en-gb/windows/uwp/xaml-platform/x-bind-markup-extension)または[this](https://msdn.microsoft.com/en) -gb/windows/uwp/data-binding/data-binding-in-depth)または[this](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlBind)または[これは(http://stackoverflow.com/questio) ns/32582303/binding-vs-xbind-static-source-as-a-default-and-their-differences-d)または[this](http://stackoverflow.com/questions/37398038/difference-between) -binding-and-xbind)?この質問は以前何度も聞かれ、答えられました。 –

答えて

1

x:bindを使用すると、モデルクラスインスタンスのメンバーだけをバインドできます。あなたはモデルクラスのインスタンスの唯一のメンバー
を結合することができ、また、あなたが(現在のオブジェクトを。だけではなくその単一のプロパティ)全体のインスタンスをバインドできるの結合を介して

//sends whole current instance to the converter. 
//(note: yes you see correct. no property is attached after Binding keyword 
    .... 
<DataTemplate x:DataType="Models:Human"> 
<StackPanel Background="{Binding Converter={StaticResource UnwantedDayColorConverter}}"> 
.... 

//you can send only instance property (Gender) to the converter 
<DataTemplate x:DataType="Models:Human"> 
       <StackPanelHorizontalAlignment="Stretch" Background="{x:Bind Gender, Converter={StaticResource UnwantedDayColorConverter}}"> 
関連する問題