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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:57:50+00:00 2026-05-26T06:57:50+00:00

I’m working on a WPF app, using .NET 4. I’m also trying to wrap

  • 0

I’m working on a WPF app, using .NET 4. I’m also trying to wrap my head about WPF Commands, and not always rely upon events, as I’ve done for upteen years. I’m trying to figure out which command to use. I’ve come across a Search command, that that appears to be a part of the NavigationCommands, which doesn’t make sense to me to use. I’ve also found the Find command, but that’s associated with Control-F, which makes me think its for finding a search in a document, like a Word document, so again, that doesn’t look right to me.

Here’s what I want to accomplish. I will have some textboxes on the windows, for things like first name, last name, SSN and DOB. I want to make it possible for the user to enter any or all of those, and then click on a button. It then performs a search against our database for all records matching the parameters the user gave. It will then put the returned results in a list box on the same window.

What WPF commmand do I use for that?

  • 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-26T06:57:50+00:00Added an answer on May 26, 2026 at 6:57 am

    No WPF Command will do this magically for you.

    You will have to write code for this.

    Now there are two options…

    1. If you are using MVVM pattern then you will have to use DelegateCommands.
    2. Otherwise RoutedComamnds will do.

    For RoutedCommands you could use a custom routed command OR use existing NavigationCommand.Search OR Find Commands, all you have to remember is to apply CommandBindings. Using CommandBindings, you have to provide an OnExecuted handler in which your logic will be put.

    Now to extract what user have typed in the TextBoxes, you could bind the textboxes to the command using CommandParameter…

    e.g.

    Below is a simply code that displays “Hello World ” when user types his / her name in the TetxBox and hits “Hit Me!” button, which has the command configured for it. The command also disables the button if user clears the textbox (i.e. invalid input).

    XAML

        <Button Command="NavigationCommands.Search"
                CommandParameter="{Binding Text, ElementName=UserNameTextBox}"
                Content="Hit Me!">
            <Button.CommandBindings>
                <CommandBinding Command="NavigationCommands.Search"
                                Executed="OnSearchCommandExecuted"
                                CanExecute="CanSearchCommandExecute"/>
            </Button.CommandBindings>
        </Button>
        <TextBox Name="UserNameTextBox"
                 Text="(Enter User Name)">            
        </TextBox>
    

    Code Behind …

        private void OnSearchCommandExecuted
           (object sender, ExecutedRoutedEventArgs e)
        {
            MessageBox.Show("Hello World " + e.Parameter.ToString());
        }
    
        private void CanSearchCommandExecute
           (object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = !string.IsNullOrEmpty(e.Parameter.ToString());
        }
    

    Hope this helps…

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
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 am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.