C# 및 XAML SemanticZoom 컨트롤을 Metro 앱에서 바인딩을 사용하려하지만 정직하게 처리 방법이 잘못되었습니다.C# 및 XAML에서 데이터 바인딩?
이<SemanticZoom x:Name="boardZoom" Height="626" Margin="10,132,10,0" VerticalAlignment="Top">
<SemanticZoom.ZoomedInView>
<GridView IsSwipeEnabled="True" x:Name="ItemsGridView">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="10,10,0,0"
HorizontalAlignment="Left" Background="White">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Width="200" Height="300"
FontFamily="Global User Interface" FontSize="40" Foreground="Black"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
<Image Source="{Binding Image}" Height="60" Width="60"
VerticalAlignment="Center" Margin="0,0,10,0" Visibility="{Binding isImage}" />
<TextBlock Text="{Binding Category}" TextWrapping="Wrap" Width="200"
FontFamily="Global User Interface" Foreground="Black"
VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</SemanticZoom.ZoomedInView>
<!--Didn't include SemanticZoom.ZoomedOutView since I'm still trying to get the ZoomedIn one working first-->
</SemanticZoom>
그리고 내 C# 코드는 :
List<PinStore.pin> pins = PinStore.CopyFromStream(response.GetResponseStream()); //returns a list of PinStore.pin objects, which have name, type, Image, isImage, and Category objects
System.Collections.ObjectModel.ObservableCollection<SemanticZoomed.zoomedIn> toSource = new System.Collections.ObjectModel.ObservableCollection<SemanticZoomed.zoomedIn>(); //should I be using ObservableCollection or something like List<> here?
foreach (PinStore.pin pin in pins)
{
SemanticZoomed.ZoomedIn toAdd = new SemanticZoomed.ZoomedIn(); //class with Title, Image, isImage, and Category objects
if (pin.type == "text")
{
toAdd.Title = pin.name;
toAdd.Image = null;
toAdd.isImage = Visibility.Collapsed;
toAdd.Category = pin.category;
}
toSource.Add(toAdd);
}
ItemsGridView.DataContext = toSource;
내가 XAML/C#에서 많은 경험을 한 적이 없다 여기에 내가 질문에, 기사 등에서 조립할에 의해 지금까지받은 한 XAML 코드입니다 , 제로 바인딩 경험. 오류가 발생하지는 않지만 ItemsGridView.DataContext = toSource;
을 ItemsGridView.ItemsSource = toSource;
으로 바꾸면 빈 Stackpanel이 GridView에 나타나며 지정한 제목 및 카테고리 값을 채울 수있는 방법을 찾지 못하는 것으로 나타났습니다. . 감사!
덕분에, 나는 그것을 밖으로 시도 할 것이다 내일 아침에 당신에게 돌아 가라 :) 종류의 오프 주제이지만() 대신 {}을 사용하는 이유를 물을 수 있습니까? 단지 궁금해서 대답하고 싶지 않다면 : D – MatthewSot
[] {}과()를 포함하여 멋지게 보이는 기호를 사용합니다. 나는 그것이 너무 많은 프로그램을 일으킨다 고 생각합니다. {then (. –
아, 의미가 있습니다. : D – MatthewSot