2010-12-23 2 views

답변

2

마이크가 말했듯이 새로운 DataBound 애플리케이션의 일부로 생성 된 코드를 살펴보십시오.

또한, 오히려 그리드에 데이터를 표시하는 것보다, 그것은 열에서 수직으로 데이터를 표시하는 아마 더 나은 :

을 :

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
    <StackPanel> 
     <TextBlock Text="Name" Style="{StaticResource PhoneTextLargeStyle}" /> 
     <TextBlock Text="{}Binding Name}" Margin="20,0,0,0" /> 
     <TextBlock Text="ID" Style="{StaticResource PhoneTextLargeStyle}" /> 
     <TextBlock Text="{Binding ID}" Margin="20,0,0,0" /> 
     <TextBlock Text="City" Style="{StaticResource PhoneTextLargeStyle}" /> 
     <TextBlock Text="{Binding City}" Margin="20,0,0,0" /> 
     <TextBlock Text="Category" Style="{StaticResource PhoneTextLargeStyle}" /> 
     <TextBlock Text="{Binding Category}" Margin="20,0,0,0" /> 
     <TextBlock Text="Others" Style="{StaticResource PhoneTextLargeStyle}" /> 
     <TextBlock Text="{Binding Others}" Margin="20,0,0,0" TextWrapping="Wrap" /> 
    </StackPanel> 
</Grid> 

그리고이 채워 때 어떻게 보이는지 볼 수있는 빠른 방법으로

public partial class MainPage : PhoneApplicationPage 
{ 
    public MainPage() 
    { 
     InitializeComponent(); 

     Loaded += MainPage_Loaded; 
    } 

    void MainPage_Loaded(object sender, RoutedEventArgs e) 
    { 
     // This would really be the data returned from the web service 
     var sampleData = new WsData 
          { 
           Name = "Girilas & Gandhi Nagar", 
           ID = "842", 
           City = "Bangalore", 
           Category = "Shopping Mall", 
           Others = "AC Types: central\n AC, Split AC Windows\nACWhirlpool:\nMicrowave Oven ..." 
          }; 

     this.DataContext = sampleData; 
    } 
} 

public class WsData 
{ 
    public string Name { get; set; } 
    public string ID { get; set; } 
    public string City { get; set; } 
    public string Category { get; set; } 
    public string Others { get; set; } 
} 
1

데이터 바인딩 프로젝트 템플릿을 사용하여 프로젝트를 만드는 것이 좋습니다. 출발점으로 사용할 수있는 것과 매우 유사한 결과를 생성하기 때문입니다.

+0

Windows Phone 7에서 DataBound priject 템플릿 사용 방법 – selladurai

+0

후속 질문에 대한 답변을 늦게 드려 죄송합니다. 새 프로젝트로 이동하면 프로젝트 템플릿에 대해 Windows Phone 데이터 바인딩 된 응용 프로그램을 선택하십시오. 이것은 당신이 볼 수있는 실제 샘플을 생성 할 것입니다. –

관련 문제