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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:44:51+00:00 2026-06-09T17:44:51+00:00

I am writing a data entry application and am having problems dealing with add

  • 0

I am writing a data entry application and am having problems dealing with add vs edit vs view ‘modes’ of the app.

The scenario: From a window, the user selects items in two combo boxes and then clicks a button. If the combo box selections don’t match an existing record, the form should open with a new record ready to have values inserted. If the selections DO match an existing record, this record should be opened with all the textboxes in the form in ‘Readonly’ mode. Should the user wish to modify the existing data, they click the form’s Edit button which sets the textboxes as ‘Editable’.

I’m new to wpf, but in my vba apps, I’d normally have a DataMode property and a ToggleControls method which would loop through the TabControl’s TabItems and then loop through the TabItems’ controls, setting the IsReadOnly property of any TextBox controls found based on the ‘DataMode’ property. However, I have doubts about whether this is the path to follow in wpf.

So, my question is, do i use the approach above? If so, how do I access the controls in a TabItem. This doesn’t work: foreach (Control ctrl in MyTabCtrl) { //if Textbox do stuff }.

If this isn’t the way to do it, can someone show me the way? I’m guessing it’s either a template / style issue or something to do with setting the data as readonly somehow, and then binding the TextBox’s IsReadOnly property to the state of the data. Edit: Oh, or that ViewStateManager thing. All of which i know little about.

  • 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-06-09T17:44:52+00:00Added an answer on June 9, 2026 at 5:44 pm

    An easy approach would be

    In Code behind declare a DependencyProperty named IsReadOnly

    public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register(
                "IsReadOnly",
                typeof (bool),
                typeof (MainWindow)
                );
    
            public bool IsReadOnly
            {
                get { return (bool) GetValue(IsReadOnlyProperty); }
                set { SetValue(IsReadOnlyProperty, value); }
            }
    

    Implement the Buttons Click event, so that IsReadOnly gets false on Click

     private void Button_Click(object sender, RoutedEventArgs e)
        {
            IsReadOnly = false;
        }
    

    Bind the TextBoxes to the IsReadonly property using DataBinding

       <TextBox IsReadOnly="{Binding Path=IsReadOnly, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Mode=OneWay}" />
    

    This binding assumes that your code behind is not your DataContext and you therefore have to bind relatively to the Window/ UserControl which the CodeBehind is applied to.

    This way the TextBoxes listen to changes on this property. When it switches, they change their ReadOnly state automatically.

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

Sidebar

Related Questions

I'm writing an aggregation application which scrapes data from a couple of web sources
I am writing data synchronization application between sql server and firebird. In firebird is
My application is SL2 reading and writing data through an Entity Framework Model exposed
I am writing a Silverlight application that will be both reading and writing data
I'm writing a .NET web application in which administrators can customize the various data
I'm writing some quick code to try and extract data from an mp3 file
I am writing a small data entry form. Data gets entered in html form
I am writing a data entry program where the last field is going to
I am writing an AHK script to automate data entry into a GUI form.
I'm writing my first master detail view in Cocoa. My data model is really

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.