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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:04:31+00:00 2026-05-19T09:04:31+00:00

I need a control to allow users to add/delete/edit rows of key/value pairs. What’s

  • 0

I need a control to allow users to add/delete/edit rows of key/value pairs. What’s the best control to use for this? Does anyone have an example? I’m quite new to WPF.

  • 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-19T09:04:32+00:00Added an answer on May 19, 2026 at 9:04 am

    I’d use a simple dialogue with two labelled text boxes, the new pair would be added to the original data which should be bound to the DataGrid so that rows are generated automatically.

    Edit: A DataGrid example solution.
    XAML:

    <Window
        ...
        DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}">
        <StackPanel Orientation="Vertical">
            <DataGrid ItemsSource="{Binding GridData}"/>
        </StackPanel>
    </Window>
    

    Code behind:
    In window class:

        private ObservableCollection<Pair> gridData = new ObservableCollection<Pair>(new Pair[]{new Pair()});
        public ObservableCollection<Pair> GridData
        {
            get { return gridData; }
        }
    

    Pair class:

    public class Pair : INotifyPropertyChanged
    {
        private string key = "Key";
        public string Key
        {
            get { return key; }
            set
            {
                if (this.key != value)
                {
                    key = value;
                    NotifyPropertyChanged("Key");
                }
            }
        }
    
    
        private double value = 0;
        public double Value
        {
            get { return value; }
            set
            {
                if (this.value != value)
                {
                    this.value = value;
                    NotifyPropertyChanged("Value");
                }
            }
        }
    
        public Pair() { }
        public Pair(string key, double value)
            : this()
        {
            Key = key;
            Value = value;
        }
    
        #region INotifyPropertyChanged Members
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        private void NotifyPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }
    
        #endregion
    }
    

    You should be able to add new pairs with the normal DataGrid functionality.

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

Sidebar

Related Questions

I need a WinForms control that will allow me to add control such as
Is there a winforms month-only picker control? I need to allow the user to
I need a control having these features: It should be possible use it in
I am making a custom control I need to add some default keybindings, microsoft
I need to provide a way to allow users to select 1 Subject, but
I'm writing a Firefox extension (add-on) to allow users to annotate any page with
I have a page where I need to allow user to add multiple options
I need to control inbound and outbound traffic to/from a linux box from within
I need a control that can list data in 3 columns, I want to
I need GUI control for audio file presentation. The language is not very important

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.