views:

41

answers:

1

I have a user control, has a Frame as a dependency property

public partial class NavigationBar : UserControl
{
    public NavigationBar()
    {
        this.InitializeComponent();
    }

    public Frame NavigationFrame
    {
        get { return (Frame)GetValue(NavigationFrameProperty); }
        set { SetValue(NavigationFrameProperty, value); }
    }

    // Using a DependencyProperty as the backing store for NavigationFrame.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty NavigationFrameProperty =
        DependencyProperty.Register("NavigationFrame", typeof(Frame), typeof(NavigationBar), new UIPropertyMetadata());
}

Using the User Control code:

<userControls:NavigationBar NavigationFrame="{Binding ElementName=masterPage, Path=frameNavigations}" />

 <Frame x:Name="frameNavigations"/>

Why the NavigationFrame dependency property still null after loading ?

Thanks in advance

+2  A: 

That will look for an element in your page with a name of masterPage, and then look for a property on that object called frameNavigations. I think you actually want to bind to the element with the name frameNavigations, so you would just write:

<userControls:NavigationBar
    NavigationFrame="{Binding ElementName=frameNavigations}"/>
<Frame x:Name="frameNavigations"/>
Quartermeister