I have a user control called AlarmSettings, the user control's resource dictionary contains an instance of my custom class "AlarmClock", the AlarmClock has a dependency property called AlarmName, why do I get the error Error "The member "AlarmName" is not recognized or is not accessible."
This is my user control:
<UserControl x:Class="ChangeSet.AlarmSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:alarm="clr-namespace:ChangeSet.Alarm;assembly=ChangeSet"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480" >
<UserControl.Resources>
<alarm:AlarmClock x:Key="alarmClock" AlarmName="{Binding ElementName=AlarmSettings, Path=Name}"/>
</UserControl.Resources>
This is my AlarmClock class:
public class AlarmClock: DependencyObject
{
public AlarmClock()
{
PopulateSettingsOptions();
}
public string AlarmName
{
get { return GetValue(AlarmNameProperty).ToString(); }
set { SetValue(AlarmNameProperty, value); }
}
public static readonly DependencyProperty AlarmNameProperty =
DependencyProperty.Register("AlarmName", typeof(string), typeof(AlarmClock), new PropertyMetadata("DefaultAlarm"));
Note: I'm trying to bind the AlarmName to the Name property of the AlarmSettings user control but even if I remove the binding and try to set the AlarmName dependency property to a string I will still get the same error.