Hi,
We are using a XamGrid inside a XamOutlookBar (also inside TabControl) :
TabControl -> TabItem -> XamOutlookBar -> OutlookBarGroup -> XamGrid
We have an issue with the XamGrid as it is not displaying data first time the TabItem/OutlookBarGroup container is selected.
Have a look at attached solution and try this :
- Run it- Click on "Tab n°3" : XamGrid appear in OutlookBarGroup "n°1", but no data are displayed even if data are loaded (using bindind).- Click on tab "Tab n°1" and go back to "Tab n°3", data are displayed (binding not updated at this point)
Can you please have a look to this "display" problem ?
Thanks for your help.
Alain.
HI,
ON the first group, set its IsSelected = true:
Here a code snippt:
<ig:OutlookBarGroup IsSelected="True" Name="grp1" Header="Grid n°1" >
Sincerely, Matt Developer Support Engineer
Please let me know if you need further assistance regarding this case.
Sincerely,
Matt
Developer Support Engineer
Hi Matt,
Thanks for your investigation.
I review the solution you posted.It works but like you did the ViewModel is instanciate twice : one time for the DataContext of the page and one time for the static resource.(twice the memory space used)
Unfortunatly this is not posible to use in our application as the ViewModel is saved when user move to new page and restored when user go back.This means the value of IsSelected is "saved" in the ViewModel.I don't understand why this cannot work with XamOutlookBar.All others components in the page are using this mecanism and it works well (charts, tabs, etc.).Do you have another solution to achieve that with XamOutlookBar ?Thanks.Alain.
You don't need two view models, you can use one. Define your ViewModel in Xaml once.
I defined it twice, just to show you how to do the binding. The IsSelected Property of the OutLookGroup is not a visual element, so you cant use datacontext binding.
You must bind it using a Static Resource.
Hi Matt,I don't have 2 view models. Il have only one but instanciated twice :
- as the data context of the page (good) - as the static resource (not so good for our case)
The 2nd one is not so good, for us, because its done each time the page is loaded, its use memory twice and it cannot be saved/restored when user move to another page and go back.
So, I tried to bind SelectedGroup property of XamOutlookBar instead. But not working because when page is restored with a not null SelectedGroup in the data context, the XamOutlookBar is trying to add this "old" group to the lits of groups.(the old group had, of course, a different hashcode than the groups instantiated when "new version" of page is loaded)
As IsSelected and SelectedGroup cannot be used in our case, I had to :
- use 'SelectedGroupChanged' event on XamOutlookBar to save the last selected group name in the context - keep locally the name of the saved selected group, after data coontext is restored (when page is re-loaded, i.e. when user go back) - use 'Loaded' event XamOutlookBar to loop in groups list to select the good one
Hope this will help someone else.
Matt, thanks for your help.
You can do this with just one instance in memory.
Define the ViewModel as a Static Resource.
Set the DataContexts to that static resource.
Hi Matt,Yes, I think your solution works when things are declared in Xaml.But in our application there is already a mecanism to save/restore page data.So, view model must be instanciate in code behind.As explain in my previous post I found another solution.Anyway, thanks for what you did for us.Alain.