Problems with binding of complex object

KeidP

New member
Sep 9, 2015
1
0
0
Visit site
Hi guys

I try binding a object with object properties inside. Anything like this :

Public class X
{
private Q P{get;set;}

public Q p
{
get { return P; }
set
{
P= value;
RaisePropertyChanged("p");
}
}
}
}
and Q definition is

public class Q is

Public class Q
{
private A A{get;set;}

public A a
{
get { return A; }
set
{
A= value;
RaisePropertyChanged("a");
}
}
}

and A class is
public class A
{
public string Name;
}

I send my object X with name "Data" to my datacontext but then never display in view. My Xaml is:

<phone:pivotItem x:Name="Details" DataContext="{Binding Data}" Margin="0">
<phone:pivotItem.Header>
<TextBlock Text="Friend Details" FontSize="35" />
</phone:pivotItem.Header>
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Path=X}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="175"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<ItemsControl ItemsSource="{Binding Path=Q}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Grid.Column="0" Orientation="Vertical" Width="Auto" HorizontalAlignment="Left" Margin="25,25,0,0">
<TextBlock Text="{Binding Path=Name}" Foreground="Black" FontSize="22" Margin="0,5,0,0"/>

Pls help me
 

Laura Knotek

Retired Moderator
Mar 31, 2012
29,405
24
38
Visit site
Moved to Developers Corner forum, since this is a topic that would be better suited for fellow developers, rather than ordinary users.
 

Catholic Tech Geek

New member
Feb 2, 2012
130
0
0
Visit site
I know it's been awhile since this post was created, but I will try my best to give a good answer anyway (for future people looking on this thread). I'm curious to know what the DataContext property of the parent of the PivotItem is. The other problem I see is that you're trying to use an ItemsControl control. ItemsControl is for use with collections. The "Data" property that you're trying to bind to isn't a collection, is it?
 

Members online

Forum statistics

Threads
323,300
Messages
2,243,598
Members
428,055
Latest member
DrPendragon