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 7940207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:19:12+00:00 2026-06-03T23:19:12+00:00

Edit : I changed the code according to Thorstens Answer, using the enum, but

  • 0

Edit: I changed the code according to Thorstens Answer, using the enum, but did not work.

I am using Dependency Properties to influence a WPF control I am creating. I’m new to WPF, so I’m not sure what I am doing wrong and I can’t find proper articles explaining it.

For example, I’m trying to define the Visibility of a control via Dep Properties. The property, in this case, would be this:

public static readonly DependencyProperty IconVisibilityBoldProperty = 
DependencyProperty.Register("IconVisibilityBold", typeof(Visibility), typeof(RTFBox),
new PropertyMetadata(Visibility.Hidden), VisibilityValidateCallback);
private static bool VisibilityValidateCallback(object value)
{
 Visibility prop = (Visibility) value;
 if (prop == Visibility.Hidden || prop == Visibility.Visible)
 {
  return true;
 }
 return false;
}
public Visibility IconVisibilityBold
{
 get
 {
  return (Visibility)GetValue(IconVisibilityBoldProperty);
 }
 set
 {
  SetValue(IconVisibilityBoldProperty, value);
 }
}

Edit: for correct XAML, look for Slugarts answer.
The XAML Entry for this, in this case a ToggleButton, would be

<ToggleButton Visibility="{Binding Path=IconVisibilityBold}" ToolBar.OverflowMode="Never" x:Name="ToolStripButtonBold" Command="EditingCommands.ToggleBold" ToolTip="Bold">
<Image Source="Images\Bold.png" Stretch="None"/>
</ToggleButton>

I’ve output the Property, it shows as “Hidden” as the Metadata Default Value should imply, but apparently I’ve done something wrong with the binding. What would I have to write there?

  • 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-03T23:19:14+00:00Added an answer on June 3, 2026 at 11:19 pm

    You are trying to binding to a property of the parent control without referencing it, and it won’t be set implicitly. You need to set the ElementName in the ToggleButton binding to be the name of the UserControl you are creating (giving it an x:Name property if it doesn’t have one already).

    <UserControl x:Name="rtfBox">
    <ToggleButton Visibility="{Binding ElementName=rtfBox, Path=IconVisibilityBold}" ... />
    ...
    </UserControl>
    

    Also you should follow the previous answers which correctly state that the Visibility property is an enum and not a string.

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

Sidebar

Related Questions

[EDIT] I changed my code according to the your answers. But now I get
EDIT: I have changed my program according to suggestions people have made but I
EDIT: I have changed the question as it was too localized and gained negative
Is there a way to know if TAdoQuery in Edit state was changed? Assuming
Edit: Read the lines in bold to find where I'm having problems. I changed
Edit: Updated code. Now works well enough. Foreword. I am an OpenGL newb tasked
For some reason this is outputting 'null'. The code seems to be right according
According to [MSDN: Array usage guidelines]( http://msdn.microsoft.com/en-us/library/k2604h5s(VS.71).aspx) : Array Valued Properties You should use
According to the documentation , __traits(hasMember, ...) is supposed to work with any type
I just had a friend of mine look over some code I'm using to

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.