2009-07-21 6 views
0

コード内のバインディング宣言(C#)内で型キャストを実行したいと思います。TypeCast内のバインディングパス

System.Windows.Data Error: 39 : BindingExpression path error: '((IPageLayout)Children[0])' property not found on 'object' ''Grid' (Name='FullPagePageViewGrid')'. BindingExpression:Path=((IPageLayout)Children[0]); DataItem='Grid' (Name='FullPagePageViewGrid'); target element is 'Label' (Name='aLabel'); target property is 'Content' (type 'Object') 

答えて

1

申し訳ありませんが、あなたがそれを行うことはできません: - :ここに私の状況を示すコードの迅速な塊だ意外に、VSを約パスが見つからない文句を言いません

Binding aBinding = new Binding(); 
aBinding.Mode = BindingMode.OneTime; 
aBinding.ElementName = "FullPagePageViewGrid"; 
//aBinding.Path = new PropertyPath("((IPageLayout)Children[0])"); // What I'd like to do - causes error 
aBinding.Path = new PropertyPath("Children[0]"); 
aBinding.Converter = new IsSelectedTextBoldConverter(); 
this.aLabel.SetBinding(Label.ContentProperty, aBinding); 

ここで私が受信エラーですその方法では、パスは「直接」にする必要があります。しかし、それはです。コンバータは何をすべきですか?;必要なキャスティングを実行するものを提供する必要があります。

+0

これは私が恐れていたものです。私は正常にコンバータを使用することができましたが、私はそれを直接ワイヤリングできるかどうかを見たいと思っていました。ありがとう! – Joel

関連する問題