Tab headers to change when individual cells in grid in each tab has dirty data in it

2 posts, 1 answers
  1. stephen
    stephen avatar
    19 posts
    Member since:
    Jul 2010

    Posted 31 May 2011 Link to this post

    I have  textboxes inside RadGridView inside a RadTabControl.
    1) My textboxes have a twoway binding to a viewmodel representing each row of the grid.
    2) All rows are inside an observable collection of these viewmodels.
    3) I have an observable collection of tabs which each have a list of those rows.

    What I want to happen is that each time there is data inside one of the textboxes, the corresponding tab header gets an asterisk in it's name, until all the textboxes on that tab are cleared. 

    The problem is that the tabs are bound to a different viewmodel than the textboxes - there is no way for the textboxes to know their viewmodel is actually inside a collection which is inside another collection where the tab headers are. 

    So i tried using a BindingValidationError control on the RadTabControl top level, and throwing an exception each time the 'set' method is run on the textbox binding looks like this:
    <TextBox Width="100" Text="{Binding NewValue, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"/>

     The BindingValidationError handler in the code-behind that did this:
        if (e.Action == ValidationErrorEventAction.Added)
                    (e.OriginalSource as Control).Background = new SolidColorBrush(Colors.Yellow);

                if (e.Action == ValidationErrorEventAction.Removed)
                    (e.OriginalSource as Control).Background = new SolidColorBrush(Colors.White);

    It doesn't seem to be working  - is this the right way to achieve what I want?
  2. Answer
    Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 01 Jun 2011 Link to this post

    Hello stephen,

    I attached a sample project illustrating how you can create an EventHandler in the GridViewRows ViewModel and use it to control a property from the TabControl ViewModel.

    I hope this approach will help you implement your functionality.

    All the best,
    Tina Stancheva
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top