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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:48:56+00:00 2026-05-16T15:48:56+00:00

Hi i have made my own UserControl, its a little windows explorer. i defined

  • 0

Hi i have made my own UserControl, its a little windows explorer.

i defined a Property in the Control that sets the Path where the Explorer should start from listing the Directory:

 public string SetRootPath
    {
        get { return rootPath; }
        set { rootPath = value; }
    }

and im binding the TreeView that i have with a method “listDirectory”

 public UserControl1()
        {
            InitializeComponent();
            this.DokumentBrowser.ItemsSource = listDirectory(SetRootPath);
        }

when im calling it and i try to set the SetRootPath Property to a local path

<mycontrol:UserControl1 SetRootPath="c:\\temp" />

the Variabel SetRootPath is everytime null and i get an Exception because nothing is assigned. So why is the Property never setted with the value that i assign?

regards

  • 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-16T15:48:57+00:00Added an answer on May 16, 2026 at 3:48 pm

    You are accessing SetRootPath in the constructor. At that point in time, XAML hasn’t yet had the chance to set your property, so it’s still null. Try to set the ItemsSource of your DocumentBrowser at a later time in the UserControl life cycle. A good choice would be the setter of SetRootPath.

    (In fact, there are a few more “WPF-like” options for doing this:

    Option A: Make SetRootPath a dependency property and change DocumentBrowser.ItemsSource during its PropertyChanged callback.

    Option B: Like Option A, but don’t handle PropertyChanged. Instead, bind the DocumentBrowser’s ItemsSource property to your SetRootPath property, using a converter which applies listDirectory.)

    PS: I’d call it RootPath, not SetRootPath.

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

Sidebar

Related Questions

I have a form and two custom UserControl that I made myself. one control
I have made Catifier.com recently, and once the user sets their own background image,
I have made my own jQuery plugin, but it has problem that values I
I have made my own php MVC framework and have also written its documentation.
I have made my own custom little blog and well, I realized it was
I have a JavaScript class that I have made and put it into its
I have made my own exception class which derives from runtime_error and is getting
I have made my own map using the google maps api. It is a
I have made my own file type (.ddd) and I made a simple program
I have made my own sms app with a reciver. Now the emulator doesn'T

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.