Problem with Binding

3 posts, 1 answers
  1. George Bill
    George Bill avatar
    8 posts
    Member since:
    Apr 2010

    Posted 03 Jun 2010 Link to this post


    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.

    CODE :
    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. Answer
    Viktor Tsvetkov
    Viktor Tsvetkov avatar
    382 posts

    Posted 08 Jun 2010 Link to this post

    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.
  3. DevCraft R3 2016 release webinar banner
  4. George Bill
    George Bill avatar
    8 posts
    Member since:
    Apr 2010

    Posted 08 Jun 2010 Link to this post


    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,
Back to Top