This sounds like it should be simple. I have a Page
declared in XAML in the normal way (i.e. with "Add new item...") and it has a custom property. I\'
You could declare your
element to be a
element instead:
That would do the trick, but you lose InitializeComponent()
and the standard designer stuff. Design mode still seems to work flawlessly, though, but I haven't extensively tested this.
UPDATE: This compiles and runs, but does not actually set MyProperty
. You also lose the ability to bind event handlers in XAML (although there may be a way to restore that which I am unaware of).
UPDATE 2: Working sample from @Fredrik Mörk which sets the property, but does not support binding event handlers in XAML:
Code-behind:
namespace WpfApplication1
{
public partial class MainWindow : Window
{
protected override void OnActivated(EventArgs e)
{
this.Title = MyProperty;
}
public string MyProperty { get; set; }
}
}
XAML: