Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadTabControl reloading content in swiching tabitems

Tags:

wpf

telerik

I'm using RadTabControl and I have a problem with reloading tabs. If I add two tabs and edit first tab content and go to the second tab and come back first tab lost the content. If I edit some tab content and click to edited tab title and go to another tab and come back it binds and changes context. I have a lost focus event for textbox(content) if I set break point to lost focus event and after running I test all situation it's good working but I need to change Note.Content property in lost focus by binding Content textbox with content property. Content property is in Note class.

xmlns:ec="clr-namespace:WpfControls;assembly=WpfControls" 

<UserControl.Resources>
        <DataTemplate x:Key="TabContent">
            <Grid>
                <ScrollViewer VerticalScrollBarVisibility="Auto">
                    <TextBox  Text="{Binding Content}" Name="ContentTextBox" MinLines="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True"/>
                </ScrollViewer>
            </Grid>
        </DataTemplate> 
    </UserControl.Resources>

 <Grid Grid.Column="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <ec:NoteBook x:Name="uiNotebook" TabContentTemplate="{StaticResource TabContent}" Margin="30" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        </Grid>


 public DataTemplate TabContentTemplate
        {
            get { return (DataTemplate)GetValue(TabContentTemplateProperty); }
            set { SetValue(TabContentTemplateProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ContentTemplate.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TabContentTemplateProperty =
            DependencyProperty.Register("TabTemplate", typeof(DataTemplate), typeof(NoteBook), new PropertyMetadata(null));

Can anybody help me? Thanks Jamshed

like image 456
Jamaxack Avatar asked Dec 08 '25 09:12

Jamaxack


1 Answers

After long researches I find the answer and I want to share it. it was IsContentPreserved property and I set it to true, it works!

<telerik:RadTabControl x:Name="tabControl" IsContentPreserved="True" ItemsSource="{Binding Tabs}">
like image 144
Jamaxack Avatar answered Dec 10 '25 11:12

Jamaxack