2012-02-03 6 views
0

私はカスタムクラス内の要素にdatabindする必要があります。私はItemSourceをtelerikのObservableCollectionとして与えました:RadTransitionControlは、添付プロパティを介しています。しかし、Imageコントロールのソースとしてイメージメンバーを提供する必要があります。私は次の方法を試みたが失敗した。Imageコントロールのソースを提供する

<Grid Background="Black"> 
     <telerik:RadTransitionControl x:Name="radControl" adRotator:AdRotatorExtensions.ItemChangeDelay="0:0:3" 
             adRotator:AdRotatorExtensions.CurrentSelectedIndex="0" 
             adRotator:AdRotatorExtensions.IndexChanged="{Binding TopItemCommand, Mode=OneWay}" 
             adRotator:AdRotatorExtensions.ItemsSource="{Binding Path=ImagePaths}" 
             VerticalAlignment="Center" 
             HorizontalAlignment="Center" Width="650"> 
      <telerik:RadTransitionControl.Transition> 
       <telerik:MotionBlurredZoomTransition /> 
      </telerik:RadTransitionControl.Transition> 

      <telerik:RadTransitionControl.ContentTemplate> 
       <DataTemplate> 
        <Image Source="{Binding Path=ImagePaths.AdImage}" /> 
       </DataTemplate> 
      </telerik:RadTransitionControl.ContentTemplate> 

     </telerik:RadTransitionControl> 
    </Grid> 
+0

のため?出力ウィンドウに表示されます。 –

+0

画像を表示せずに画面を空白にしただけです。 – logeeks

+0

ビジュアルスタジオ出力ウィンドウ(表示 - >出力)を意味します。バインディングに関連する問題がある場合は、常にそこにチェックする必要があります。ここであなたの旅を救うかもしれません。 ;) –

答えて

1

ImagePathsオブジェクトは既にアイテムのDataContextとして設定されています。これは、バインディングがオブジェクトのインスタンスで既に指し示している(つまり、話す)ことを意味します。だから、ImagePaths.AdImageに縛ると言うと、あなたが探しているプロパティを見つける方法がわかりません。良いニュースは、あなたがしなければならないのは、オブジェクト上のパスを提供することです - ImagePaths部分(およびドット)を削除して、あなたは良いことがあるはずです。例えば

...

class something 
{ 
    public string someImage {...} 
} 

<DataTemplate> <!--------- the data context of this item is an instance of 
          my "something" class, so i need to set the path 
          to be the property on the object ---> 

    <Image Source="{Binding Path=someImage}" /> 

</DataTemplate> 

here is a very helpful article on debugging bindings in WPF
バインドエラー何であったかを詳細here is an excellent article on MSDN
here is a datatemplate article from Dr. WPF

+0

logeeks

+2

デバッグ用バインディングの記事を参照してください。 /bea.stollnitz.com/blog/?p=52バインディングのデバッグメッセージを追加する方法を説明します –

関連する問題