No buttons on dialog

Mar 5, 2012 at 3:17 PM


I have another - beginner - question.

I have created a window that I want to show as a dialog:

<catel:DataWindow x:Class="TestCatel.Presentation.WPF.View.IngredientListWindow"
    <!-- Resources -->
    <ListView ItemsSource="{Binding IngredientList}">
            <GridView AllowsColumnReorder="true" >
                <GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Ingredient" Width="Auto"/>
                <GridViewColumn Header="Danger" Width="Auto">
                                <TextBlock Text="{Binding Path=DangerClass}" Style="{StaticResource ListViewUnSelected}"/>
                                <TextBox Text="{Binding Path=DangerClass, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" Style="{StaticResource ListViewSelected}" />

public class IngredientListViewModel : ViewModelBase

I call it this way:

var viewModel = new IngredientListViewModel();
var uiVisualizerService = GetService<IUIVisualizerService>();
But no buttons (OK, Cancel) are displayed. I thought that they would be added automatically. I checked the example application Catel.Examples.WPF.Validation but I fail to find the place where the OK and Cancel button are added.

thanks, Gorroux

Mar 5, 2012 at 6:56 PM

The OK and Cancel buttons are added by the DataWindow itself. However, you can customize this in the constructor of the view. Can you show me the code-behind for IngredientListWindow?

Also, you might be interested in the latest beta, it no longer requires generic base classes for the views :)

Thanks in advance!

Mar 6, 2012 at 8:54 AM

I'm trying to convert my test application to 3.0 right now.

As I use another project for the viewmodels I need to add a naming convention:

var viewModelLocator = ServiceLocator.Instance.ResolveType<IViewModelLocator>();

But where do I have to put this code? If in MainWindow constructor it is to late - the framework cannot find the viewmodel. If I put in in the App.xaml codebehind I get the following error message:

The type 'Catel.MVVM.IViewModelLocator' is not registered, not even in an external container

Also, is it correct, that the Datawindow is now also non-generic?


Mar 6, 2012 at 8:58 AM

Mainly in the app startup. However, the services are registered by default by the first ViewModelBase creation. Thus, if you want to use it earlier, you can do something like this:

var serviceLocator = ServiceLocator.Instance;

serviceLocator.RegisterType<IViewModelLocator, ViewModelLocator>();

var viewModelLocator = serviceLocator.ResolveType<IViewModelLocator>();

All views are now available as non-generic, thus the DataWindow, UserControl, Page and PhoneApplicationPage are all available as non-generic now (but the generics are still there for backward compatibility).

See this documentation for all options regarding the ViewModelLocator:

Mar 6, 2012 at 9:00 AM

btw, tonight we will release an official beta including the templates, docs, etc. Both via nuget and an official beta installer.

Mar 6, 2012 at 9:30 AM

The buttons now work fine, I did indeed miss the point.

I can now access the viewModel locator, but it still does not work. Also the viewLocator does not work opening a new model.

If I register the view explicitly and using the GetViewModelType() overloads everything works fine.

I will attach my project to the IsDirty issue. Maybe you can have a look at this topic as well.

Thanks, Gorroux

Mar 6, 2012 at 9:47 AM

On more little suggestion about the naming conventions for the locators: I "had" a UserControl called "ReceiptUserControl". So the postfix was non of your defined postfixes (should be named ReceiptControl), so the automatic resolve could not work.

You could let the user add a list of known postfixes to the locators next to the naming conventions.


Mar 6, 2012 at 9:50 AM

Hmmm, interesting. I will add UserControl to the list.

Mar 6, 2012 at 9:52 AM

It's really all about habit, isn't it :)

Mar 6, 2012 at 9:54 AM

Yes, we used to write the UI like this:


etc, but now we put everything into the Views folder, seems easier to understand for most people. But, luckily we support most used naming conventions (and allow several naming conventions to be used together at once). The beta we will release tonight will contain the UserControl postfix fix.

Mar 6, 2012 at 9:56 AM


I believe Catel will by indeed my choice for the next big project coming on. Support is great. Thanks!