2012-12-05 3 views
0

중첩 된 나열된 상자를 만드는 중입니다. 기본적으로 하나의 목록 상자에서 여러 클래스를 바인딩해야하기 때문에 중첩 된 나열된 상자를 만들 수 없습니다.중첩 된 목록 상자에서 여러 클래스로 바인딩

여기가 XAML 페이지에서 할 수있는 작업은 다음과 같습니다

<ListBox Name="abcd" Margin="10,0,30,0" ItemsSource="{Binding Title}"  SelectionChanged="ListBox_SelectionChanged" Height="486" Width="404" FontSize="20"> 
       <ListBox.ItemTemplate> 
        <DataTemplate > 
         <StackPanel Margin="0,0,10,0" Width="380" Height="140"> 
          <Grid > 
          <TextBlock Text="{Binding cdata}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}" /> 
           <ListBox Name="ab" ItemsSource="{Binding Description}" FontSize="14"> 
            <ListBox.ItemTemplate> 
             <DataTemplate> 
              <StackPanel Width="380" Height="100"> 
               <Grid> 
                <TextBlock Text="{Binding cdata}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}" /> 
               </Grid> 
              </StackPanel> 
             </DataTemplate> 
            </ListBox.ItemTemplate> 
           </ListBox> 
          </Grid> 
         </StackPanel>        
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 
옵니다 "ABCD"이 클래스는 단지 하나 개의 문자열 필드가 Description.Both 클래스에 클래스 제목과 "AB"와 결합되어야한다

, "cdata". xaml.cs에서

가 나는 수행

abcd.ItemsSource=from article in root.openfooty.news.article 
          select new Classes.Title 
          { 
            cdata = article.title.cdata 
          }; 

     ab.ItemSource = from article in root.openfooty.news.article 
          select new Classes.Description 
           { 
            cdata = article.description.cdata 
           }; 

은 "ABCD"바인딩 잘 작동하지만,와 "AB"는이

어떤 도움 "남 AB 나던 현재 컨텍스트에 존재"라고 많이 감사하겠습니다. 감사합니다 : D

+0

같은 하나 개의 목록 상자가, 당신은 같은 제목 클래스에리스트 박스와 같은 article.title.cdata 모두 구속력 ?? – nkchandra

+0

죄송합니다. 그건 오타 였고 다른 클래스에 바인딩했습니다. 여기 코드가 있습니다. ab.ItemSource = root.openfooty.news.article의 기사는 새로운 Classes.Description { CDATA = article.description.cdata }를 선택 ; –

답변

0

당신이 쓰지 않는 이유는이

public class TitleDescription 
{ 
    public string title { get; set; } 
    public string description { get; set; } 
} 

와 데이터 바인딩을 시도 같은 하나의 클래스?

abcd.ItemsSource=from article in root.openfooty.news.article 
         select new Classes.TitleDescription 
         { 
           title = article.title.cdata, 
           description = article.description.cdata 
         }; 

그리고 CSHARP 코드에서이

<ListBox Name="abcd" Margin="10,0,30,0" SelectionChanged="ListBox_SelectionChanged" Height="486" Width="404" FontSize="20"> 
      <ListBox.ItemTemplate> 
       <DataTemplate > 
        <StackPanel Margin="0,0,10,0" Width="380" Height="140"> 
         <Grid > 
          <TextBlock Text="{Binding description}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}" /> 
          <TextBlock Text="{Binding title}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeLarge}" /> 
         </Grid> 
        </StackPanel> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 
관련 문제