Quantcast
Channel: Caliburn.Micro: Xaml Made Easy
Viewing all articles
Browse latest Browse all 1760

New Post: TabViewModel - Data not displaying

$
0
0
Hi, I am trying to create a wpf app using a TabControl in my shell and have hit a block regards dealing with TabViewModels/TabViews. I seem to get the data, but it doesn't display in any of the controls. Unfortunately, I have tried so many things, I'm not sure which way I should be heading or even whether I should start again.

Background: I have an entity framework model that I am connecting to via a WCF service. My service and DAL are in separate projects. I am trying to use StructureMap for DI. The project shows details of Callers, their Calls, and the CallQueries made during each call (to make it more common, the domain concepts match to Customers, Orders and OrderDetails). The user selects from a list of callers in the shell view, and clicks 'Show Caller Details' which should add a new Tab to the TabControl containing details of that Caller. The 'Caller details' tab includes a list of calls (in its own view) which the user can select from and then view details relating to that call in a different tab - so far I haven't even tried to get this bit working, but it is the reason for having a separate TabViewModel (ie both CallerDetailsVM and CallDetailsVM will extend TabViewModel).

What happens: When the user selects the Caller Details button, the new tab is created and presented but the widgets in the view don't contain the data about the caller - except for the DisplayName (which is a property of the base TabViewModel).

First, am I doing the Exports right?
[Export(typeof(IShell))]
ShellViewModel : Conductor<IScreen>.Collection.OneActive, IShell
[Export(typeof(IScreen))]
TabViewModel : Screen
[Export(typeof(TabViewModel))]
CallerDetailsViewModel : TabViewModel
Second, do I need a TabView, given there is no concrete instantiation of the TabViewModel? I don't think it's hurting either way, but I don't think it is necessary.

Third, and most importantly, what am I doing wrong? :-) Where does the data go? I can see I have the correct data as the DisplayName on the Tab is correct (ie shows the Caller's name) and debug messages show I'm getting other fields. I have tried various forms of syntax for the CallerDetails widgets. Eg for the Caller's 'GivenNames' text box I have tried the following: x:Name="GivenNames", x:Name="Caller_GivenNames"; when these didn't work, I tried to revert to the traditional binding syntax, using Text="{Binding GivenNames}", Text="{Binding Caller.GivenNames}"; both with and without the x:Name syntax. Interestingly, none of these seem to give the usual Binding Errors when the binding engine can't match the data to the control.

Things that might help with diagnosis:
Solution: Image

Bootstrapper.Configure():
  {
     container = new StructureMap.Container(new RepositoryRegistry());
   }
RepositoryRegistry:
public RepositoryRegistry()
{
  For<Caliburn.Micro.IWindowManager>().Use<WindowManager>();
  For<Caliburn.Micro.IWindowManager>().Singleton();
  For<DLGCContactLog_Caliburn.Interfaces.IShell>().Use<ShellViewModel>();
  For<ICallerService>().Singleton().Use(() => new CallerServiceClient());
}
My apologies for the super-long first post. This mvvm stuff is not easy to grok (but Caliburn is the most understandable framework I've used, so I'm keen to makes sense of it all). If there's anything else I can provide to help, just let me know.

Many thanks

Viewing all articles
Browse latest Browse all 1760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>