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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:34:32+00:00 2026-06-06T13:34:32+00:00

we have a wpf-window with some textboxes and a datagrid. the textboxes descripe a

  • 0

we have a wpf-window with some textboxes and a datagrid.
the textboxes descripe a parent (class a) object and the datagrid lists a collection of “childs” (class b => not derived from class a).
the childs can inherit values from the parent.

for example if the parent (class a) has a property Foo then the child object (class b) has a property Nullable which can either override the value of the parent or inherit the value of the parent.

now the datagrid should display the value in gray (if it is inherited) or in black (if the user overrides the value in the grid cell).

Unfortunatly Binding to InheritedText doesnt work. Does someone have any idea?

 <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
           <UserControls:InheritedTextBoxControl 
                 Text="{Binding Path=?}"
                 InheritedText="{Binding Path=?}" />
      </DataTemplate>
 </DataGridTemplateColumn.CellTemplate>

Thanks in advance
Tobi

–UPDATE–

xaml of InheritedTextBoxControl:

<UserControl x:Class="Com.QueoMedia.CO2Simulationstool.WPF.Utils.UserControls.InheritedTextBoxControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         mc:Ignorable="d"
         Width="Auto"
         Height="Auto"
         Name="cnt">

<Grid x:Name="LayoutRoot"
      Background="White">
    <TextBox TextChanged="TextBoxTextChanged"></TextBox>
    <TextBlock Name="inheritedText"
               IsHitTestVisible="False"
               Margin="4,0"
               VerticalAlignment="Center"
               Opacity="0.5"
               FontStyle="Italic"></TextBlock>
</Grid>

CodeBehind:

public partial class InheritedTextBoxControl : UserControl {

    private bool _isInherited;

    public static readonly DependencyProperty InheritedTextProperty = DependencyProperty.Register("InheritedText", typeof(String), typeof(InheritedTextBoxControl), new PropertyMetadata(""));
    public static DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(InheritedTextBoxControl), new PropertyMetadata(default(string)));

    public InheritedTextBoxControl() {
        InitializeComponent();
    }

    public string InheritedText {
        get { return (string)GetValue(InheritedTextProperty); }
        set {
            SetValue(InheritedTextProperty, value);
            inheritedText.Text = value;
        }
    }

    private bool IsInherited {
        get { return _isInherited; }
        set {
            _isInherited = value;
            if (value) {
                inheritedText.Opacity = 0.5;
            } else {
                inheritedText.Opacity = 0;
            }
        }
    }

    public string Text {
        get { return (string)GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }

    private void TextBoxTextChanged(object sender, TextChangedEventArgs e) {
        if (((TextBox)sender).Text.Length > 0) {
            IsInherited = false;

        } else {
            IsInherited = true;
        }
        Text = ((TextBox)sender).Text;
    }
}
  • 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-06T13:34:34+00:00Added an answer on June 6, 2026 at 1:34 pm

    If someone is interested in the solution:

    we did it using a CellTemplate containing a CustomControl name MaskedTextbox that has three properties (MaskedText, Text, IsMaskTextVisible) and a CellEditingTemplate to override the data.

    The values are bound to an InheritableValueViewModel.

    Tobi

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

Sidebar

Related Questions

I have a WPF Window defined in XAML like this: <Window x:Class=com.some.company.window xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have a WPF window with some textboxes, comboboxes and a grid using MVVM
I've been having trouble with some databinding with WPF. I have a class to
In WPF I have one window opening a second window that allows some data
I have observed some unexpected or at least not-perfectly-matching-my-needs behaviour of textboxes bound to
I am building a WPF application and I have some DependencyProperties in my window's
I have a WPF window( using c# as code behind) that has some text
I have a WPF Window with WindowStyle set to none. Is there some way
I have a ComboBox on a WPF window that is giving me some heartache,
I have the following grid in my WPF Window (yes the class Window); <Grid

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.