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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:46:32+00:00 2026-05-14T04:46:32+00:00

This is a weird problem. I am using a dataform, and when I edit

  • 0

This is a weird problem. I am using a dataform, and when I edit the data the save button is enabled, but the cancel button is not.

After looking around a bit I have found that I have to implement the IEditableObject in order to cancel an edit. Great I did that (and it all works), but now the commit button (Save) is grayed out, lol. Anyone have any idea’s why the commit button will not activate any more?

Xaml

<df:DataForm x:Name="_dataForm"                      
             AutoEdit="False"
             AutoCommit="False"
             CommandButtonsVisibility="All">                     
    <df:DataForm.EditTemplate >
        <DataTemplate>
            <StackPanel Name="rootPanel"
                Orientation="Vertical"
                df:DataField.IsFieldGroup="True">
                <!-- No fields here. They will be added at run-time. -->                        
            </StackPanel>
        </DataTemplate>
    </df:DataForm.EditTemplate>
</df:DataForm>

binding

DataContext = this;
_dataForm.ItemsSource = _rows;

…

TextBox textBox = new TextBox();                                        
Binding binding = new Binding();
binding.Path = new PropertyPath("Data");
binding.Mode = BindingMode.TwoWay;
binding.Converter = new RowIndexConverter();
binding.ConverterParameter = col.Value.Label;

textBox.SetBinding(TextBox.TextProperty, binding);
dataField.Content = textBox;

// add DataField to layout container
rootPanel.Children.Add(dataField);

Data Class definition

public class Row : INotifyPropertyChanged , IEditableObject
        {                               
            public void BeginEdit()
            {
                foreach (var item in _data)
                {
                    _cache.Add(item.Key, item.Value);
                }
            }

            public void CancelEdit()
            {
                _data.Clear();

                foreach (var item in _cache)
                {
                    _data.Add(item.Key, item.Value);
                }

                _cache.Clear();

            }

            public void EndEdit()
            {
                _cache.Clear();

            }

            private Dictionary<string, object> _cache = new Dictionary<string, object>();

            private Dictionary<string, object> _data = new Dictionary<string, object>();

            public object this[string index]
            {
                get
                {
                    return _data[index];
                }
                set
                {
                    _data[index] = value;

                    OnPropertyChanged("Data");
                }
            }

            public object Data
            {
                get { return this; }
                set
                {
                    PropertyValueChange setter = value as PropertyValueChange;
                    _data[setter.PropertyName] = setter.Value;
                }
            }

            public event PropertyChangedEventHandler PropertyChanged;

            protected void OnPropertyChanged(string property)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(property));
                }
            }
        }
  • 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-14T04:46:32+00:00Added an answer on May 14, 2026 at 4:46 am

    When you create fields in the code-behind they are actually only created on the form and not “in memory”. You can try this yourself by clicking on the cancel button, when you edit again the form will be blank, and the fields will need to be recreated.

    So when you create the fields you need to put the following code in order to actually create the fields.

     if (_dataForm.Mode == DataFormMode.Edit)
                    {
                        _dataForm.CommitEdit();
                        _dataForm.BeginEdit();
                    }
    

    When you do this the buttons will behave as expected.

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

Sidebar

Ask A Question

Stats

  • Questions 368k
  • Answers 368k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Entity Framework designer is terrible - I've had the… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If by "hijack" you meant sniff the packets then what… May 14, 2026 at 5:11 pm
  • Editorial Team
    Editorial Team added an answer If you want two actions to be atomic, embed them… May 14, 2026 at 5:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.