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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:33:32+00:00 2026-05-26T17:33:32+00:00

I have a Window that serves as a dialog in a WPF application. This

  • 0

I have a Window that serves as a dialog in a WPF application. This dialog has an “OK” and a “Cancel” button. I am setting the DataContext of the Window to an instance of an object in my application. The user can change the values of the properties of the object within the Window. If a user clicks “Cancel”, I want to revert the property values back to their original values. Is there an easy way to do this in WPF?

For instance, I know with RIA data services there is RejectChanges. Is there something similar on the client-side with WPF?

Thanks!

  • 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-26T17:33:33+00:00Added an answer on May 26, 2026 at 5:33 pm

    In object which is set to DataContext (ideally it should be ViewModel in MVVM approach) expose two commands

    public ICommand CancelCommand { get; set; }
    public ICommand OkCommand { get; set; }
    

    Then for the buttons assign these commands like shown below

    <Button Command="{Binding CancelCommand}" ... />
    

    You’ve to keep two copies of object, a copy should be created by Deep Copy or if an object has a few editable fields you can keep those as class fields. Basically on initialization stage do backup editable object properties, then bind to DataContext editable version of object. In Cancel Command handler – restore from a backup copy…

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

Sidebar

Related Questions

I have a gateway application that comes up with a login dialog and then
I have a client server based windows forms application that needs an administrator only
I have a page that calls window.print(); at the bottom of the page. I
I have a submit button when i click on that button i am having
In my ASP.Net application I have a requirement that when a user clicks on
Lets suppose I have an .NET client application that connects to a WCF service,
We have implemented a popup window as a modal dialog using the IE method:
I have built an ASP.NET MVC 3 web application (with exlusively Razor/cshtml pages) that
I have a Windows Form app that creates a window and monitors for entries
I've got a Django template that initiates the Facebook OAuth process by doing: window.location='https://www.facebook.com/dialog/oauth?client_id=MY_CLIENT_ID&redirect_uri=http%3A//localhost%3A8000/fbpanel/explore-python'

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.