3

How the binding class in the class in Windows Phone

 3 years ago
source link: https://www.codesd.com/item/how-the-binding-class-in-the-class-in-windows-phone.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How the binding class in the class in Windows Phone

advertisements

My problem is this, i have a class Match:

Match.cs

public class Match
    {
        public int Id { get; set; }
        public Team Team_1 { get; set; }
        public Team Team_2 { get; set; }
        public string Date { get; set; }
        public string Hour { get; set; }
        public string Local { get; set; }
        public string Statium { get; set; }
    }

and this class have Two objects Team, in Team i have this attributes:

Team.cs

 public class Team
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Image { get; set; }
...

im try Binding the Match object in my view:

 <ListBox Name="lbMatches" Height="480" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Width="60" Orientation="Vertical">
                                        <TextBlock  Text="{Binding Date}" FontFamily="Segoe WP Semibold" />
                                        <TextBlock Text="{Binding Hour}" FontFamily="Segoe WP Semibold"/>
                                    </StackPanel>
                                    <TextBlock VerticalAlignment="Center" Text="Brazil" FontSize="32" FontFamily="Segoe WP Semibold" Margin="20,0,10,0"/>
                                    <Image Source="{Binding Thumb}"/>
                                    <TextBlock VerticalAlignment="Center" Text="x" FontSize="32" Margin="10,0" Opacity="0.8"/>
                                    <Image Source="/Assets/team_image/thumbs/croacia.png"/>
                                    <TextBlock VerticalAlignment="Center" Text="Croatia" FontSize="32" FontFamily="Segoe WP Semibold" Margin="10,0,20,0"/>

                                </StackPanel>
                            </DataTemplate>
                            </ListBox.ItemTemplate>
                    </ListBox>

But have a crucial duvid, how i make to acess the Name of Team Binding a Match ? bind the team of Match how make this ?


You can navigate to the relationship from Match to Team in a binding, e.g.

<TextBlock Text="{Binding Team_1.Name}"/>




About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK