Please forgive the obtuse title, not sure how best to phrase my problem...
I have written a custom control "CustomControl" in project Foo. It has a dependency property "Title" which is a string:
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register(
"Title",
typeof(string),
typeof(CustomControl),
PropertyMetadata.Create("Default Title")
);
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
In my Generic.xaml file, I am trying to set the value of "Title" with a Setter node:
<Style TargetType="local:CustomControl">
<!-- Setter for Template property -->
<Setter Property="Title" Value="Any String" />
</Style>
The app chokes as soon as it tries to render the control, saying it cannot find the "Title" property in my control:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in Foo.exe but was not handled in user code
WinRT information: The property 'Title' was not found in type 'Foo.Controls.CustomControl'. [Line: X Position: Y]
Additional information: Unspecified error
Am I doing something wrong here? Is this not allowed?
When I break in the debugger I can see the Title property on the object, so I'm pretty perplexed.