Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8113719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:55:13+00:00 2026-06-06T02:55:13+00:00

I have implemented my own simple version of a navigation window, mainly because navigation

  • 0

I have implemented my own simple version of a navigation window, mainly because navigation windows journal does not give me control over how many children can exist. So I am using a border inside a window and changig its child everytime. As children I am using a UserControl. I want to bind the title of my Window to the Title property of my current child. Somehow I cannot figure out a way to do it.

MainWindow XAML:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="525"
    Height="350"
    Background="AliceBlue"
    Title="{Binding Path=Child.Title,
                    ElementName=borderContent}">
<DockPanel>
    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
        <Button Content="&lt;-" x:Name="btnBack"  />
        <Button Content="->" x:Name="btnForward"  />
    </StackPanel>
    <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
        <Button Content="1" Click="Button_Click_1" />
        <Button Content="2" Click="Button_Click_2" />
    </StackPanel>
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <Border x:Name="borderContent"  />
    </ScrollViewer>
</DockPanel>

MainWindow Code behind:

using System;
using System.Windows;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.borderContent.Child = new ContentPage("Title 1");
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            this.borderContent.Child = new ContentPage("TITLE 2");
        }
    }
}

UserControl XAML:

<UserControl x:Class="WpfApplication1.ContentPage"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>
    <TextBlock Text="{Binding Source={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=Title}" />
</Grid>

User Control Code behind:

using System.Windows;
using System.Windows.Controls;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Content.xaml
    /// </summary>
    public partial class ContentPage : UserControl
    {
        public string Title
        {
            get { return (string)this.GetValue(ContentPage.TitleProperty); }
            set { this.SetValue(ContentPage.TitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(ContentPage), new UIPropertyMetadata(string.Empty));

        public ContentPage(string Title)
        {
            this.Title = Title;
            InitializeComponent();

        }
    }
}

Somehow the binding inside the UserControl is also not working. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:55:14+00:00Added an answer on June 6, 2026 at 2:55 am

    The problem is that the Child property of a Borderisn’t a DependencyProperty so there is no change notification. You’ll have to update the Binding manually everytime you change the Child

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        this.borderContent.Child = new ContentPage("Title 1");
        UpdateTitleBindingExpression();
    }
    
    private void Button_Click_2(object sender, RoutedEventArgs e)
    {
        this.borderContent.Child = new ContentPage("TITLE 2");
        UpdateTitleBindingExpression();
    }
    private void UpdateTitleBindingExpression()
    {
        BindingExpressionBase beb = BindingOperations.GetBindingExpressionBase(this, Window.TitleProperty);
        if (beb != null)
        {
            beb.UpdateTarget();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Symfony2 and FOS User Bundle issue... I have implemented my own login form in
I have an own Tree object implemented in PHP. Say we have a tree
I have an assignment to implement my own version of Collections.fill() and Collections.reverse(). The
I have this simple layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical >
The code I'm working with has its own smart pointer implementation which does simple
Have stepped on my own toes with what I thought was a very simple
I have extended the GLSurfaceView and implemented my own GLSurfaceView.Renderer to create my first
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented pagination to my data, but the problem is I only have
I have implemented a table view with multiple threads. Currently when a user taps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.