Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my DependencyProperty not accessible?

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.

like image 299
Harry Len Avatar asked Jan 28 '26 19:01

Harry Len


1 Answers

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.

like image 86
Hitsa Avatar answered Jan 30 '26 23:01

Hitsa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!