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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:34:37+00:00 2026-06-15T08:34:37+00:00

I’ve created an user control to Browse for file, it is basically composed of

  • 0

I’ve created an user control to “Browse” for file, it is basically composed of one textbox and one button.

It has several properties, allowing me to select either a directory, an existing(open file dialog) or an inexisting file(save file dialog), specifying filter, …

I’m using dependency properties like this:

    public static readonly DependencyProperty FilePathProperty = DependencyProperty.Register(
        "FilePath",
        typeof(String),
        typeof(BrowseFileControl),
        new PropertyMetadata(default(String), InvokeFilePathChanged)
    );
    public String FilePath { get { return (String)GetValue(FilePathProperty); } set { SetValue(FilePathProperty, value); } }

    private static void InvokeFilePathChanged(DependencyObject property, DependencyPropertyChangedEventArgs args)
    {
        BrowseFileControl view = (BrowseFileControl)property;
        view.InvokeFilePathChanged((String)args.OldValue, (String)args.NewValue);
    }
    protected virtual void InvokeFilePathChanged(String oldValue, String newValue)
    {
        InvokePropertyChanged("FilePath");
    }

In my view, I’ve a listbox allowing me to select which “configuration” I want to edit, and all my fields(including my usercontrol) are bound to CurrentConfiguration(and the CurrentConfiguration is Bound to the SelectedItem).

My problem:
The first load is always OK, but if I select another configuration, it just doesn’t update and keep the old text.

my binding is like this:

<userContols:BrowseFileControl  Grid.Row="4" Grid.Column="1" 
    Margin="2" FilePath="{Binding CurrentConfiguration.TagListFile, 
    ValidatesOnDataErrors=true, NotifyOnValidationError=true}"
    IsFolder="False" Filter="All files (*.*)|*.*" CanBeInexistantFile="False"/>

If I use a simple Textbox, with the exact same binding, it is updated correctly!

<TextBox Grid.Row="4" Grid.Column="1" 
    Text="{Binding CurrentConfiguration.TagListFile,ValidatesOnDataErrors=true, NotifyOnValidationError=true}" 
    Margin="2"/>

I also don’t see any binding error in the output windows of visual studio.

So what can be wrong with my binding?

Edit: The xaml of the UserControl:

<Grid DataContext="{Binding ElementName=uxBrowseFileControl}">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <TextBox Padding="2" Text="{Binding FilePath, ValidatesOnDataErrors=true, NotifyOnValidationError=true}"/>
    <Button Content="Browse" Grid.Column="1" Padding="2" Command="{Binding BrowseCommand}"/>
</Grid>

uxBrowseFileControl is the name of the <UserControl>

Edit 2: In fact if I change something through the userControl, it isn’t replicated in the model too :/

Edit3: I put a “Mode=TwoWay” into the binding of my currentItem.FilePath->UserControl, and it seems to work now, but why ? The TextBox with the same binding was working!

  • 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-15T08:34:39+00:00Added an answer on June 15, 2026 at 8:34 am

    You should remove your DependencyProperty’s change callback. You don’t need any special logic in order to make Dependency Properties update the UI when they’re changed – this is already built into dependency properties.

    This is all you need:

    public static readonly DependencyProperty FilePathProperty = DependencyProperty.Register(
        "FilePath",
        typeof(String),
        typeof(BrowseFileControl),
        new PropertyMetadata(default(String))
    );
    
    public String FilePath { get { return (String)GetValue(FilePathProperty); } set { SetValue(FilePathProperty, value); } }
    

    You might want to also set your dependency property to bind TwoWay by default, (The Text property for the TextBox control also does this):

    public static readonly DependencyProperty FilePathProperty = DependencyProperty.Register(
        "FilePath",
        typeof(String),
        typeof(BrowseFileControl),
        new FrameworkPropertyMetadata(default(String), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)
    );
    

    This way you won’t have to explicitly set Mode=TwoWay whenever you bind that property.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.