Problem with binding Title of WPF window on property in shell view model class

Jan 6, 2011 at 1:31 PM

Hi, I have simple problem with binding property in shell view model class on Title property of WPF Window- it’s shell.

My shell view look like this:

<Window x:Class="Spirit.Views.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding Path=Title}" >
    <Grid>
        <ContentControl x:Name="ActiveItem" />
    </Grid>
</Window>

shell view model class:

[Export(typeof(IShellViewModel))]
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive, IShellViewModel
{
    public string Title { get; set; }

    public ShellViewModel()
    {
        Title = "Spirit";
    }
}

If I run app Title of shell view (WPF window) is Namespace.ShellViewModelClass, no value of property Title in shell view model class.

If I active some screen in shell view, Title property of window is Namespace.ViewModelClass.

How can I remove this behavior? Thank for advice.

Jan 6, 2011 at 2:05 PM

The default behaviour will bind the Window.Title to the view-model DisplayName. Unless the DisplayName is already used, you can avoid to define a Title property.

Jan 6, 2011 at 2:19 PM

Thank, I don’t know about DispalyName property.