문제

I'm creating a WPF wizard control following the MSDN Structured Navigation example. My working XAML looks like this, where my WizardBase is a subclass of System.Windows.Navigation.PageFunction, and MyPageOne is a subclass of WizardBase (namespaces and class names changed for privacy):

<local:WizardBase
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:My.Namespace" 
    x:Class="My.Namespace.MyPageOne"
    KeepAlive="True"
    WindowTitle="Page One">

This works great: when I navigate to this page in the wizard, the dialog title changes to "Page One". But now I want to internationalize that string. So I changed it to:

WindowTitle="{Binding Source={x:Static local:LocalizedStrings.PageOneTitle}}"

which fails at runtime with:

A 'Binding' cannot be set on the 'WindowTitle' property of type 'MyPageOne'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.

What's special about WindowTitle that it can be set but not bound? I'm assuming that I've just made some kind of novice error.

도움이 되었습니까?

해결책

Oh, duh, it's really easy. I just want:

WindowTitle="{x:Static local:LocalizedStrings.PageOneTitle}"

That is, set it directly rather than applying via a binding. I was making it way too complicated...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top