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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:34:07+00:00 2026-06-05T19:34:07+00:00

I have a custom UserControl with a custom DependencyProperty. To paint a better picture

  • 0

I have a custom UserControl with a custom DependencyProperty. To paint a better picture of how I’m using this, the UserControl is the left navigation indicator in a wizard-like control. The left nav control exists inside of each of the controls that represent a step in the wizard. Inside of the left nav control, I am toggling visibility and setting visual properties of several child controls with a few converters with code similar to the following. I can’t use a simple style selector or style-selecting converter because the entire structure of each row in my StackPanel is different if the item is selected or not.

This is a ton of code to be repeating all over my control to bind to a single custom property. Is there a shorter form version of the following or a cleaner way to implement this?

<Polygon
    Visibility="{Binding
    RelativeSource={RelativeSource Mode=FindAncestor,
    AncestorType=UserControl},
    Path=Selected,
    Converter={StaticResource myCustomConverter},
    ConverterParameter='Expected String'}">
...

The parent views supply a single property to customize the child control:

    <!-- Left Column -->
    <views:LeftNavControl Selected="Item to Select..." />
  • 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-05T19:34:08+00:00Added an answer on June 5, 2026 at 7:34 pm

    There are some things you could do, but I would not describe them as neither a cleaner/shorter way to implement it. They are fairy easy to implement if you are using a MVVM approach.

    The first thing you could do is getting rid of the RelativeSource/AncestorType in your bindings to find the location of the bound property.
    If both/all your controls (it’s not clear how many controls you use) would share the same viewmodel you could bound the same viewmodel property to views:LeftNavControl.Selected, and to all of your toggled visibility controls.

    The second thing you could do, is a more radical approach that would clean your xaml, and it will also make your myCustomConverter obsolete, but will move some of the business logic in your viewmodel. This works best in case you have a multitude of Polygons/other controls that need visibility toggle.
    You could have a StepXVisiblity property in your viewmodel, and you could calculate it every time views:LeftNavControl.Selected changes and your Polygon(s) xaml will look like:

    <Polygon Visibility="{Binding StepXVisiblity}">
    

    A simple example of the above explanation would be:

    <StackPanel>
        <TextBox Text="{Binding Step, UpdateSourceTrigger=PropertyChanged}" />
        <TextBlock Text="One" Visibility="{Binding StepOneVisible}" />
        <TextBlock Text="One" Visibility="{Binding StepOneVisible}" />
        <TextBlock Text="Two" Visibility="{Binding StepTwoVisible}" />
        <TextBlock Text="Two" Visibility="{Binding StepTwoVisible}" />
    </StackPanel>
    

    ViewModel:

    public class MyVM : DomainBase
    {
        private int step;
    
        public int Step
        {
            get 
            { 
                return step; 
            }
            set 
            { 
                step = value;
                OnPropertyChanged("Step");
                OnPropertyChanged("StepOneVisible");
                OnPropertyChanged("StepTwoVisible");
            }
        }
    
        public Visibility StepOneVisible
        {
            get
            {
                return step == 1 ? Visibility.Visible : Visibility.Collapsed;
            }
        }
    
        public Visibility StepTwoVisible
        {
            get
            {
                return step == 2 ? Visibility.Visible : Visibility.Collapsed;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I start, I have this code inside of a Custom Usercontrol: private DependencyProperty
I have a custom UserControl which has a DependencyProperty ItemTemplate of type DataTemplate. I
I have a custom control that inherits from UserControl , and I can't get
I have a custom base user control in silverlight. <UserControl x:Class=Problemo.MyBaseControl 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
I have a custom UserControl that I created as a navigation menu that parses
I have a Custom usercontrol that I want to enlarge. I tested this whit
When I call this custom control, I have to put the attribute values in
I have an custom UserControl that displays an image, i'm trying to use this
I have a custom templated control(toolbar) that contains a custom usercontrol(button) The button uses
I have a class inheriting from UserControl, with a custom DependencyProperty. I put a

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.