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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:14:52+00:00 2026-05-15T05:14:52+00:00

I have a simple usercontrol that uses a simple custom panel where I just

  • 0

I have a simple usercontrol that uses a simple custom panel where I just overrode the Orientation and Measure functions.

What I want to do is to have a property in the usercontol to control the orientation

So I basicaly have

UserControl
 --> Listbox
   --> MyPanel

And I want a property for the usercontrol that can be set in xaml (of type System.Windows.Controls.Orientation ) that I can bind to from my custom panel (or a different approach if binding isnt the right way to do it)

It would be a bonus if that property could show up in the properties window and you could select vertical or horizontal.

And a super bonus if I could change the property at design time and have the listbox/

  • 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-05-15T05:14:53+00:00Added an answer on May 15, 2026 at 5:14 am

    First of all you would add a Orientation property to your UserControl:-

        public Orientation Orientation
        {
            get { return (Orientation)GetValue(OrientationProperty); }
            set { SetValue(OrientationProperty, value); }
        }
    
        public static readonly DependencyProperty OrientationProperty =
                DependencyProperty.Register(
                        "Orientation",
                        typeof(Orientation),
                        typeof(YourNewUserControl),
                        new PropertyMetadata(Orientation.Vertical));
    

    The way you bind to it from MyPanel is via the UserControl’s root element. Give the root element a name (typically this is a Grid with the name “LayoutRoot”).

    <ListBox ...>
      <ListBox.ItemsPanel>
         <ItemsPanelTemplate>
            <MyPanel Orientation="{Binding Parent.Orientation, ElementName=LayoutRoot}" />
         <ItemsPanelTemplate>
      </ListBox.ItemsPanel>
    

    I dunno about the properties window but that should just work.

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

Sidebar

Related Questions

I have a custom UserControl which uses a simple ITemplate: <asp:Panel runat=server ID=pnlExpander CssClass=expander>
I have a simple UserControl for database paging, that uses a controller to perform
I have some userControl that contain simple button. I want to bind the button
I have a simple custom user control that uses jqGrid. the control is as
I have a relatively simple setup. I have a custom usercontrol that has a
I have a custom usercontrol and I want to do something relatively simple. When
I have a partial view (UserControl) that implements a simple pager in my Asp.Net
I have a made a simple UserControl that allows a user to drag a
I have a UserControl that I want to participate in data binding. I've set
I have a simple UserControl that I've created that simply allows a user 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.