I have MasterDetailPage layout.for DetailContent I have contentpresenter in my page, I am loading usercontrol in that contentpresenter.
Usercontrol is having some header fields, command bar, and ListView and GridView.
In Master section I am loading some list and displaying the details of selected item in details header section, also based on the selected value I am loading other lists and displaying in listview and gridview.
I have bind the object to contentpresenter's content property. object class looks like below
SampleClass
{
class1 header {get; set;}
Observablecollection<class2> listviewitems {get; set;}
Observablecollection<class3> gridviewitems {get; set;}
}
In my code behind i am loading the data like this,
SampleClass objMain = new SampleClass();
objMain.header = await viewmodel.Getheader();
objMain.listviewitems = await viewmodel.GroupUsersList(objMain.header.groupid);
objMain.gridviewitems = await viewmodel.GetChatList(objMain.header.groupid);
Binding the above object to content presenter
<ContentPresenter x:Name="DetailContentPresenter" Grid.Column="1" Grid.RowSpan="2" Content="{x:Bind objMain ,Mode=OneWay}">
I am binding this data in UserControl like below, I have stackpanel in usercontrol in which I am binding header data.
<StackPanel>
<TextBlock Name="txtGroupName" Text="{Binding header.name}"/>
<TextBlock Name="txtGroupType" Text="{Binding header.ptype}" />
<TextBlock Name="txtGroupDate" Style="{ThemeResource smallText}">
<Run>Created on:</Run>
<Run Text="{Binding header.startdate}"></Run>
</TextBlock>
</StackPanel>
I have one gridview and listview in which i am binding listviewitems and gridviewitems like below.
<GridView x:Name="GroupMemberGridView"
ItemsSource="{Binding listviewitems}"
ItemTemplate="{StaticResource groupMemberGridViewTemplate}"
Grid.Row="3"
ItemClick="GridView_ItemClick"
IsItemClickEnabled="True"
Margin="5 0 0 0">
<ListView x:Name="GroupMemberListView"
ItemTemplate="{StaticResource groupMemberListViewTemplate}"
ItemsSource="{Binding gridviewitems}"
ShowsScrollingPlaceholders="True"
Grid.Row="3"
ItemClick="ListView_ItemClick"
IsItemClickEnabled="True">
Now issue here is when i am using {x:bind objMain} to bind to the content of content presenter it is loading usercontrol with no data, however the object which i have bound to content presenter is having data.
One more observation that I found is when I am using {Binding objMain} for contentpresenter's Content property it is loading data initially but when I click on MasterList Item it is not updating data. However I am assigning the changed value to ContentPresenter's Content property when Master list item is clicked.but when the same page reload after i navigate to some other page and comeback ,it is displaying the data which was changed
Listreference likw thisobjMain.listviewitems = await viewmodel.GroupUsersList(objMain.header.groupid);, try to add items to this list. - ravi kumar