3

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.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Harry Len
  • 135
  • 2
  • 7

5 Answers5

3

i had moved my project from one Location to another and got the same issue with dependency property when I opened it again. I just rebuild it and errors got resolved.

Purohit Hitesh
  • 1,018
  • 16
  • 28
1

I had the same problem when accessing a dependency property from XAML in Visual Studio. I just rebuilt the project.

Purohit Hitesh
  • 1,018
  • 16
  • 28
Tim Butler
  • 105
  • 1
  • 2
  • 13
1

This warning popped up again recently for me. Since everything seemed correct, and whenever XAML gives me this kind of weird behavior, I resort to removing bin & obj folders, which did the trick (once again).

xtds
  • 2,453
  • 2
  • 19
  • 12
0

What is the DataContext of your userControl?

Add an empty constructor to your class alarmClock.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Daniel
  • 9,312
  • 3
  • 48
  • 48
  • I have not set the data context, I'm trying to just bind, in XAML, to the Name property of the user control in which it resides, can I do that? I do have a parameterless constructor for the AlarmClock class, although it's not empty, just wasn't showing it in my example, have updated it. – Harry Len May 03 '13 at 23:28
0

Open the "Configuration Manager..." in the VS. Check if your projects are in the same platform, e.g: x64.

Siamca
  • 31
  • 6