This is a migrated thread and some comments may be shown as answers.

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

1 Answer 39 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
stephen
Top achievements
Rank 1
stephen asked on 01 Jun 2011, 02:21 AM
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.my 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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 01 Jun 2011, 01:03 PM
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
Tags
TabControl
Asked by
stephen
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or