대부분의 자습서에서는 Windows Phone 7 용 Silverlight 응용 프로그램의 데이터 바인딩에서 저자가 사용하고 관찰 할 수있는 컬렉션을 보았습니다. 바인딩 할 시간이 지나도 데이터가 변경되지 않는 것으로 보입니다.이 데이터가 필요합니까? 왜 그냥 목록을 사용할 수 없습니까?Bindings는 관찰 가능한 컬렉션이어야하며, 왜 작동하지 않습니까?
각 방법의 장단점은 무엇입니까? :)
또한 다음 코드가 작동하지 않는 이유는 무엇입니까? 그것은 나에게해야하는 것처럼 보입니다. 당신이 볼 수 있듯이
List<Contributor> people = new List<Contributor> { new Contributor("Danny", "www.dannybrown.com") };
contributorsListBox.ItemsSource = people;
XAML
<!--Panorama item two-->
<!--Use 'Orientation="Horizontal"' to enable a panel that lays out horizontally-->
<controls:PanoramaItem Header="contributors">
<!--Double line list with image placeholder and text wrapping-->
<ListBox x:Name="contributorsListBox" Margin="0,0,-12,0" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,17">
<!--Replace rectangle with image-->
<Rectangle Height="100" Width="100" Fill="#FFE5001b" Margin="12,0,9,0"/>
<StackPanel Width="311">
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
<TextBlock Text="{Binding RSSUrl}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PanoramaItem>
바인딩
C# 기여자 클래스
public class Contributor
{
public string Name;
public string RSSUrl;
public Contributor(string name, string rssURL)
{
Name = name;
RSSUrl = rssURL;
}
}
C 번호 항목은 각 항목과 연관된 빨간색 사각형을 가지고있다. 바인더 목록에서 컨트 리뷰 터의 양을 변경할 때마다 올바른 크기의 빨간색 직사각형이 나타나기 때문에 바인딩이 작동하는 것으로 확신합니다.
누구든지 아이디어가 있습니까?
감사합니다. 대니.
쉬운 수정 방법입니다. 그 눈 깜짝 할 사이에 얼마나 자주 눈이 보이지 않는지. 감사 :) – DanTonyBrown