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

Problem with Binding

2 Answers 203 Views
This is a migrated thread and some comments may be shown as answers.
George Bill
Top achievements
Rank 1
George Bill asked on 03 Jun 2010, 08:30 AM

I've already created a topic in this forum, and I need your help once again.
I work with the same configuration (it's the same application) : Telerik + MS Prism
Link : Close tabs - RadTabControl + Prism

I have a problem with the Binding and RadTabControl.
I have a button to add a RadTabItem in my RadTabControl, and the content of the RadTabItem work with a ContentTemplate.
The content is a form with some TextBox and each textbox has a Binding with an Object in my Model.

So, here the XAML code of my RadTabControl :
<telerik:RadTabControl Name="RadTabControlAddress" SelectionChanged="RadTabControlAddress_SelectionChanged"
                        <Style TargetType="{x:Type telerik:RadTabItem}"
                            <Setter Property="ContentTemplate"
                                        <Grid Name="Grid"
                                                <ColumnDefinition Width="100" /> 
                                                <ColumnDefinition Width="*"/> 
                                                <RowDefinition /> 
                                            <TextBlock Text="{Loc address1}" Grid.Row="0" Grid.Column="0"></TextBlock> 
                                            <TextBox Grid.Row="0"  Grid.Column="1" Text="{Binding Adresse.Adresse1 }" Height="30" Margin="5"></TextBox> 
(I deleted some field for a short version)

I have a simple RadButton with this event :
private void AddAddressTab() 
            RadTabItem itemToAdd = new RadTabItem() 
                Header = "New Tab" 
            RadTabControlAddress.SelectedIndex = RadTabControlAddress.Items.Count - 1; 

The constructor in my XAML.cs is :
public AjouterView(AjouterViewModel model) 
            // Sauvegarde du model dans un attribut de la classe. 
            _model = model; 
            // On se sert de notre model en tant que DataContext. 
            this.DataContext = model; 

In my Model I have two attribute :
private IAdresse _adresse = null
        public IAdresse Adresse 
            get { return _adresse; } 
                _adresse = value; 
My Model implement INotifyPropertyChanged - (And sorry for french name...)

The AddAddress() Method (in the model) :
public void AddAddress() 
            IAdresse address = new Adresse("Just a test"); 
            Adresse = address; 

I not include the system to change the address when we select an other Tab.

The first time we add an address (add a Tab in the TabControl), the binding doesn't work. I need to add two address for work. I don't find why ! The binding work only if I click the Button (to add an other address) if there is already a Tab in the TabControl.

You can download a demo here : Download

If you need more informations, please tell me.
Thank you in advance for your answer.


[EDIT] : Nobody shall have the beginning of solution ? I don't find how to fix this problem !

2 Answers, 1 is accepted

Sort by
Viktor Tsvetkov
Telerik team
answered on 08 Jun 2010, 12:26 PM
Hello George Bill,

Thank you for contacting us. Attached you can find a modified version of your project. Could you please have a look at it and let me know how it works for you. I'd be glad to further assist you.

Viktor Tsvetkov
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.
George Bill
Top achievements
Rank 1
answered on 08 Jun 2010, 02:30 PM

It's perfect,  thank you !
I learnt WPF a few months ago and some techniques are not evident for me. So thanks again for this reply.
I also had think to use ItemSource but I had not used it correctly.
Now the code is simpler.

(I mark your Reply as Answer)

Thanks Telerik Team and Best Regards,
Telerik rocks,
Asked by
George Bill
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
George Bill
Top achievements
Rank 1
Share this question