0
votes

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

1
Instead of changing the original List reference likw this objMain.listviewitems = await viewmodel.GroupUsersList(objMain.header.groupid);, try to add items to this list. - ravi kumar
okay, I will try this. But the problem is also with the header items where I am displaying the objmain.header as header.name and so on. it is also not loading data. so can you please explaing that as well. and to remind you one thing that this all are part of usercontrol the listview and the header items.which I am loading in contentpresenter. - Vijay Joshi
Can anyone please help me on this?. I am able to load the data now but it is not getting refreshed when I am clicking on the Master List Item. - Vijay Joshi
only if you show your click handler code. - ravi kumar
private async void OnItemClick(object sender, ItemClickEventArgs e) { SelectedGroup = e.ClickedItem as class1; _objMain.header = SelectedGroup; userlist = await ViewModel.GroupUsersList(SelectedGroup.groupid); _objMain.userslist = userlist; objMain = _objMain; DetailContentPresenter.Content = objMain; } - Vijay Joshi

1 Answers

1
votes

I've checked your SampleClass. It has not implemented INotofyPropertyChanged interface. When your "header" property's value is changed, it would not notify UI. That's the reason why your code didn't work.

As a result, please implement INotofyPropertyChanged interface for your SampleClass.