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

  • Home
  • SEARCH
  • 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 277439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T01:04:46+00:00 2026-05-12T01:04:46+00:00

Seriously, it seems like every time I want to make my UI elements talk

  • 0

Seriously, it seems like every time I want to make my UI elements talk to each other, I end up coding a new, custom, IValueConverter :(. Someone tell me that I’m doing it wrong, please!

Examples:

  • I wanted a button to be enabled only if my textbox contained a valid URI. Great, time to code up a UriIsValidConverter!
  • Oh oops, I also wanted to disable it while I’m processing something. I guess now I need to code up a UriIsValidAndBoolIsFalseMultiConverter!
  • I want to display a list of files in a certain directory (specified by a textbox) inside a listbox. I guess I need a DirectoryPathToFileList converter!
  • Oh hey, I want icons for each of those files in the listview. Time for a FileInfoToBitmap converter!
  • I want my status to be red if my status-string contains “Error”, and green otherwise. Yay, I get to code up a StatusStringToSolidColorBrushConverter!

I’m really thinking this isn’t that much better than the old Windows Forms method of just wiring up everything manually using TextChanged events (or whatever). Which I guess is still an option. Is that what people actually do, perhaps, and I’m trying too hard to make everything fit into the databinding paradigm?

So yeah, please tell me if this is really how WPF coding is—or if I’m doing it wrong, and if so, what I should be doing.

  • 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-12T01:04:46+00:00Added an answer on May 12, 2026 at 1:04 am

    Your approach is perfectly valid (though I would use a multibinding for the second example, rather than a such a specialised converter), though by placing all your logic into the XAML you are producing very high coupling between the way the application looks and the way that it behaves, because of this you may want to look into the MVVM pattern to separate those things out.

    Under the MVVM pattern your XAML (the view) just contains very simple data bindings into a ViewModel which handles all the logic and updates the view through the INotifyPropertyChanged interface. The code for your third example may look something like:

    public class DirectoryManagerViewModel : INotifyPropertyChanged
    {
        private string _directory;
    
        public string Directory
        {
            get { reutrn _directory; }
            set
            {
                if (_directory != value)
                {
                     _directory = value;
                     OnPropertyChanged("Directory");
                     if (IsValidDirectory(value))
                     {
                         PopulateFiles();
                     }
                }
            }
        }
    
        public ObservableCollection<FileViewModel> Files { get; private set; }
    
        private bool IsValidDirectory(string directory)
        {
              //return if the directory exists etc.
        }
    
        private bool PopulateFiles()
        {
             //Populate Files with files in directory
        }
    }
    

    Where FileViewModel is another view model which contains the name and the icon for a file.

    The advantage of this approach is that the ViewModels can be reused with other views and other technologies such as ASP.NET or Winforms so you are not locked into the WPF stack. (alos if you work in an environment where there are designers responsible for the look and developers responsible for the behaviour, this helps define those boundaries)

    At the end of the day though this logic does need to go somewhere and while there are better and worse ways to architect your application you are still going to be writing code that takes a string and converts it into a series of filenames and icons somewhere.

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

Sidebar

Related Questions

This seems like a pretty obvious, basic thing to expect from the Graph API
Devise is giving me a pretty hard time. For now, everything else seems to
Sorry it seems like a repeated question, BUT I think I don't qualify to
Seriously, I've trawled MSDN and only got half answers - what do the columns
Seriously. On a 22 monitor, it only covers maybe a quarter of the screen.
I have been seriously disappointed with WPF validation system. Anyway! How can I validate
With a seriously big .NET site/solution (100's of assemblies), are there any tools available
Not that it is seriously burdensome to type :My_custom_foobar() instead of just :my_custom_foobar() but
A reliable coder friend told me that Python's current multi-threading implementation is seriously buggy
I'm dealing with an issue with my current employer that has seriously made me

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.