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

  • Home
  • SEARCH
  • 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 9220441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:20:56+00:00 2026-06-18T03:20:56+00:00

I am trying to get a label bound to two properties to react to

  • 0

I am trying to get a label bound to two properties to react to a change in the second.

The basis behind this is changing a unit label for a field when switching between metric and imperial:

Image http://s7.postimage.org/wmw3vofmj/test.png

The XAML code is below:

<Label Name="UnitLabel" Grid.Column="1" Foreground="#FF1414AA" HorizontalContentAlignment="Right" VerticalContentAlignment="Center" Padding="2,2,5,2">
    <Label.Content>
        <MultiBinding Converter="{units:UnitConvertor}" Mode="OneWay">
            <Binding Path="Unit" />
            <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=base:MainForm, AncestorLevel=3}" Path="Document.Units" />
        </MultiBinding>
    </Label.Content>
</Label>

The label is hosted on a user control, which the actual document has many of:

Image http://s9.postimage.org/47hvp9uyn/test.png

The Document object is shown below:

public class Document : DependencyObject
{
    public static readonly DependencyProperty UnitsProperty =
        DependencyProperty.Register("Units", typeof (UnitSet), typeof (Document), new PropertyMetadata(default(UnitSet)));

    public UnitSet Units
    {
        get { return (UnitSet) GetValue(UnitsProperty); }
        set { SetValue(UnitsProperty, value); }
    }

    public Document()
    {
        Units = UnitSet.Imperial;
    }
}

I then try and set the Units property:

private void ChangeUnit(object sender, RoutedEventArgs e)
{
    if (sender == Metric)
    {
        Document.Units = UnitSet.Metric;
    }
    else if (sender == Imperial)
    {
        Document.Units = UnitSet.Imperial;
    }
}

However, the unit labels fail to update. What do I need to do to fix this? Apologies if anything obvious has been missed, I started WPF two days ago.

  • 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-18T03:20:58+00:00Added an answer on June 18, 2026 at 3:20 am

    I don’t know your full XAML tree, but I think your AncestorLevel is incorrect. I’m guessing MainForm is your root element but you’re saying in that binding that you’re looking for the 3rd MainForm above that label. Try eliminating the AncestorLevel altogether. It defaults to 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the value of this label: <label id=name class=sub_heading><?php echo $_SESSION['lastname'].,
I'm trying to get a label on a button to be on two or
I'm trying to get wxCheckBox to have sensitive label like it is in some
I'm trying to get the value of the Text property of an asp:label with
I am trying to get the coordinates of a component, for example a label.
As the title suggests, I'm trying to get the caption of the associated label
im trying to get the parent of this input but it just wont, i
I have a DetailsView bound to an EntityDataSource and am trying to get the
I am new to ASP.NET and I'm trying to get a Label to update
Right, I'm trying to get a label with text in it (done already obviously),

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.