I'm having trouble setting up the custom control that I created. Here is the control source:
namespace SilverlightStyleTest
{
public class AnotherControl: TextBox
{
public string MyProperty { get; set; }
}
}
In the same namespace and project, I am trying to create an installer style for MyProperty, for example:
<UserControl x:Class="SilverlightStyleTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Local="clr-namespace:SilverlightStyleTest">
<UserControl.Resources>
<Style x:Name="AnotherStyle" TargetType="Local:AnotherControl">
<Setter Property="Width" Value="200"/>
<Setter Property="MyProperty" Value="Hello."/>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Local:AnotherControl Style="{StaticResource AnotherStyle}"/>
</Grid>
</UserControl>
I get a runtime error: Invalid MyProperty attribute value for Property property. [Line: 9 Position: 30]
I canβt understand what happened to the style in order to cause this error. I also tried to "fully qualify" the property name as "Local: AnotherControl.MyProperty", but that didn't work either.
source
share