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

RadTabControl RadTabItems in a RadDataForm

7 Answers 193 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Nishant
Top achievements
Rank 1
Nishant asked on 12 Jul 2018, 06:47 PM

Hi,

In the application (WPF - MVVM) I am working on, there is a RadDataForm inside which I have implemented a RadTabControl with 2-3 RadTabItems. Also there are "ReadOnlyTemplate" and "EditTemplate" for the RadDataForm.

There is an issue with particular operations. I will try my best to explain the situation. But let me know if further details are needed.

In "ReadOnlyTemplate" mode of the DataForm, I have a few fields that are DataFormDataFields. But these values are DataFormComboBoxFields when the RadDataForm is in "EditTemplate" mode. So when I Edit the form and change tabs and then save/cancel the changes, then when the RadDataForm goes back to the "ReadOnlyTemplate" mode, but the DataFormDataFields of these fields that were DataFormComboBoxFields in "EditTemplate" mode show blank values. but if I edit and not change the tabs in edit mode and then save/cancel changes, then everything is perfect. The bug is only when I change tabs in edit mode and then save/cancel changes .

It would be helpful if anyone can help me figure if its a bug or is it something I am doing wrong here.

-Nishant

7 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Jul 2018, 02:53 PM
Hello Nishant,

I will check your case and I am going to get back to you tomorrow.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Martin Ivanov
Telerik team
answered on 18 Jul 2018, 12:54 PM
Hello Nishant,

Note that the tab control is reloading its content each time you change the selected tab. I will guess that this is the core of the issue. Can you try setting the IsContentPreserved property of RadTabControl to True and see how it goes? If this doesn't work I would ask you to post several code snippets that show your set up and which can be assembled into a runnable project.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Nishant
Top achievements
Rank 1
answered on 18 Jul 2018, 01:41 PM

Hello Martin,

 

Setting the "IsContentPreserved" property to true in RadTabControl didn't work for me.

 

I have attached my code below for reference. I basically have a raddataform inside which resides a Radtabcontrol and its radtabitems...

 

 

CODE:

 

 

<telerik:RadDataForm Grid.Row="1"
                     Grid.Column="0"
                     Grid.ColumnSpan="2"
                     Grid.RowSpan="2"
                     x:Name="editOnlyContent"
                     EditEnding="editOnlyContent_EditEnding"
                     HorizontalAlignment="Left"
                     CurrentItem="{Binding EditVM, Mode=TwoWay}"
                     CommandButtonsVisibility="All"
                     AutoEdit="False"
                     MinWidth="900"
                     IsEnabled="True"
                     AutoGenerateFields="False"
                     Margin="5">

            <telerik:RadDataForm.ReadOnlyTemplate>
                <DataTemplate>
                    <ContentControl>
                        <telerik:RadTabControl x:Name="readOnlyTabControl"
                                               IsContentPreserved="True"
                                               Visibility="Visible"
                                               SelectedIndex="{Binding ReadOnlySelectedIndex}">
                            <telerik:RadTabControl.Items>
                                <telerik:RadTabItem Header="Header1"
                                                    Name="Header1"
                                                    IsSelected="True"
                                                    Visibility="Visible">
                                    <telerik:RadTabItem.Content>
                                        <Border Background="White">
                                            <StackPanel Margin="0,20,0,0">
                                                <telerik:DataFormDataField IsReadOnly="True"
                                                                           Margin="0,10,0,0"
                                                                           Label="Label1"
                                                                           DataMemberBinding="{Binding Binding1, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
                                            </StackPanel>
                                        </Border>
                                    </telerik:RadTabItem.Content>
                                </telerik:RadTabItem>

                                <telerik:RadTabItem Header="Header2"
                                                    Name="Header2"
                                                    Visibility="{Binding IsSomething, Converter={StaticResource booleantoVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}">
                                    <telerik:RadTabItem.Content>
                                        <Border Background="White">
                                            <StackPanel Margin="0,20,0,0">
                                                <telerik:DataFormDataField IsReadOnly="True"
                                                                           Label="Label2"
                                                                           Margin="0,10,0,0"
                                                                           Visibility="{Binding IsSomething, Converter={StaticResource booleantoVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}"
                                                                           DataMemberBinding="{Binding Binding2, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
                                            </StackPanel>
                                        </Border>
                                    </telerik:RadTabItem.Content>
                                </telerik:RadTabItem>
                            </telerik:RadTabControl.Items>
                        </telerik:RadTabControl>
                    </ContentControl>
                </DataTemplate>
            </telerik:RadDataForm.ReadOnlyTemplate>

            <telerik:RadDataForm.EditTemplate>
                <DataTemplate>
                    <ContentControl>
                        <telerik:RadTabControl x:Name="editTabControl"
                                               SelectedIndex="{Binding EditSelectedIndex}">
                            <telerik:RadTabControl.Items>
                                <telerik:RadTabItem Header="Header3"
                                                    Name="Header3"
                                                    IsSelected="True"
                                                    Visibility="Visible">
                                    <telerik:RadTabItem.Content>
                                        <Border Background="White">
                                            <StackPanel Margin="0,20,0,0">
                                                <telerik:DataFormDataField Name="Name1"
                                                                           Margin="0,10,0,0"
                                                                           IsReadOnly="True"
                                                                           Label="Label3"
                                                                           DataMemberBinding="{Binding Binding1, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
                                            </StackPanel>
                                        </Border>
                                    </telerik:RadTabItem.Content>
                                </telerik:RadTabItem>

                                <telerik:RadTabItem Header="Header4"
                                                    Name="Header4"
                                                    Visibility="{Binding IsSomething, Converter={StaticResource booleantoVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}">
                                    <telerik:RadTabItem.Content>
                                        <Border Background="White">
                                            <StackPanel Margin="0,20,0,0">
                                                <telerik:DataFormDataField Name="Name2"
                                                                           Margin="0,10,0,0"
                                                                           Visibility="{Binding IsSomething, Converter={StaticResource booleantoVisibilityConverter}, UpdateSourceTrigger=PropertyChanged}"
                                                                           Label="Label4"
                                                                           DataMemberBinding="{Binding Binding2, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
                                            </StackPanel>
                                        </Border>
                                    </telerik:RadTabItem.Content>
                                </telerik:RadTabItem>

                            </telerik:RadTabControl.Items>
                        </telerik:RadTabControl>
                    </ContentControl>
                </DataTemplate>
            </telerik:RadDataForm.EditTemplate>

0
Martin Ivanov
Telerik team
answered on 23 Jul 2018, 08:51 AM
Hello Nishant,

I've used your code in order to test the issue but I wasn't able to reproduce it. May I ask you to give the project a try and let me know if I am missing something? Also, if you can reproduce the issue in the attached project can you tell me how exactly you did this and also can you record a video showing the steps to reproduce it?

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Nishant
Top achievements
Rank 1
answered on 23 Jul 2018, 12:46 PM

Hello Martin,

As I have explained in my first post, there is no problem when it is in "Edit mode" or just "read only mode". But the issue occurs when you have a save/cancel operation in "edit mode". Then you make changes , switch tabs and then if you save/cancel and the form goes from "edit mode" to "read only mode", that is when the values of certain fields go blank (as explained above in my first post).

Let me know if you have any questions.

 

-Nishant

0
Nishant
Top achievements
Rank 1
answered on 23 Jul 2018, 01:02 PM

Hey Martin,

I figured out what the issue was. I was setting "IsContentPreserved = true" only in ReadOnlyMode of the raddataform and not in the editmode as well. Once i did that, the issue is resolved. it was a miss on my part. thanks for your time and input.

 

-Nishant

0
Martin Ivanov
Telerik team
answered on 24 Jul 2018, 08:44 AM
Hi Nishant,

I am glad to hear that you managed to resolve the issue.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TabControl
Asked by
Nishant
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Nishant
Top achievements
Rank 1
Share this question
or