2012-02-23 5 views
-1

編集:バインディングドライブ私クレイジー

XAML:

SilverlightHelloWorld.Deserialize.schedule 

XAML:

<TextBlock Text="{Binding Path=CurrentShows}" Grid.Row="1"/> 

は、次の出力を生成

<TextBlock Text="{Binding Path=CurrentShows.Today}" Grid.Row="1"/> 

<TextBlock Text="{Binding Path=CurrentShows.Today.Date}" Grid.Row="1"/> 

デバッグモード中にエラーまたは出力が発生します。

Anysuggestions?


OldStatement:

私はここで静かなだけでなく、複雑な例を持っている、 は最高のは、私は私のコードで始めています。

これは私の分離コードです:私が取得しようとしています

Mainpage.xaml.cs

schedule currentshows; 
    public schedule CurrentShows 
    { 
     protected set 
     { 
      if (currentshows != value) 
      { 
       currentshows = value; 
       OnPropertyChanged("CurrentShows"); 
      } 
     } 
     get 
     { 
      return currentshows; 
     } 
    } 

schedule.cs

[XmlRoot] 
    public class schedule : INotifyPropertyChanged 
    { 
     public event PropertyChangedEventHandler PropertyChanged; 


     DayCollection today; 
     [XmlElement("DAY")] 
     public DayCollection Today 
     { 
      set 
      { 
       if (today != value) 
       { 
        today = value; 
        OnPropertyChanged("Today"); 

       } 
      } 
      get 
      { 
       return today; 
      } 
     } 

     private void OnPropertyChanged(string p) 
     { 
      if (PropertyChanged != null) 
       PropertyChanged(this, new PropertyChangedEventArgs(p)); 
     } 

    } 

DayCollection.cs

public class DayCollection : INotifyPropertyChanged 
    { 
     public event PropertyChangedEventHandler PropertyChanged; 

     ObservableCollection<TimeCollection> timecol; 
     [XmlElement("time")] 
     public ObservableCollection<TimeCollection> TimeCol 
     { 
      set 
      { 
       if (timecol != value) 
       { 
        timecol = value; 
        OnPropertyChanged("TimeCol"); 

       } 
      } 
      get 
      { 
       return timecol; 
      } 
     } 

     string date; 
     [XmlAttribute(AttributeName = "attr")] 
     public string Date 
     { 
      set 
      { 
       if (date != value) 
       { 
        date = value; 
        OnPropertyChanged("Date"); 

       } 
      } 
      get 
      { 
       return date; 
      } 
     } 

     private void OnPropertyChanged(string p) 
     { 
      if (PropertyChanged != null) 
       PropertyChanged(this, new PropertyChangedEventArgs(p)); 
     } 

    } 

Stringプロパティ "Da私のXaml to Show-Upで "te" しかし、私はちょうど解決策を得ていません。

私はまったく助けに感謝します、ありがとうアドバンス!

+0

最初にやるべきことはデータバインディングのデバッグメッセージを上げている//私は.stack.imgur.com/MF8i5.png次に、出力ウィンドウを再実行して確認し、そこにどのようなエラーがあるかを確認します。 – Will

+0

標準ではありませんか?さて、私はもう一度チェックし、エラーでもそれらをオンにして、それはうまくコンパイルされません。エラーなし、警告なし、何もありません。 – user1021605

+0

実行中はコンパイル中ではありません。 – Will

答えて

0

私はプロジェクトにコードをコピーした、あなたはのTextBlockの結合

<TextBlock Text="{Binding Today.Date}" Grid.Row="1"/> 

を設定する代わりに、このラインを使用しますが、私はあなたが外のデータを設定しているか、あなたのコードから言うことができない場合、それは動作します結合。ます。http:ここで私はメインページのコンストラクタに含ま何すなわちLayoutRootは、TextBlockのの親をある

currentshows = new schedule(); 
currentshows.Today = new DayCollection(); 
currentshows.Today.Date = "hallo"; 
LayoutRoot.DataContext = currentshows; 

<Grid x:Name="LayoutRoot"> 
<TextBlock Text="{Binding Today.Date}"/> 
</Grid> 
関連する問題