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

Relative Layout bug inside RadSlideView

2 Answers 17 Views
SlideView
This is a migrated thread and some comments may be shown as answers.
Kyrylo
Top achievements
Rank 1
Kyrylo asked on 19 Oct 2019, 07:08 AM

I am using RadSlideView in my project. It contains of ContentViews each of them is RelativeLayout with some content. Previously I was using "RelativeToParent" constraing, but now I need to use "RelativeToView". If I use RelativeToView constaint, I have this exception: "System.ArgumentNullException: 'Value cannot be null. Parameter name: key'. This exception occurs only when I place my relative layout inside the SlideVIew and use RelativeToView constraint.

In this case exception occurs:

<telerikPrimitives:RadSlideView>
    <telerikPrimitives:RadSlideView.ItemsSource>
        <x:Array Type="{x:Type ContentView}">
            <ContentView>
                <RelativeLayout>
                    <Label x:Name="lbl"
                           Text="RelativeLayout"
                           RelativeLayout.XConstraint = "{ConstraintExpression Type=RelativeToParent,
                           Property=Width, Factor=0.5, Constant=-50}"
                           RelativeLayout.YConstraint = "{ConstraintExpression Type=RelativeToParent,
                           Property=Height, Factor=0.5, Constant=-150}" />
                    <BoxView Color="Blue"
                             RelativeLayout.XConstraint = "{ConstraintExpression Type=RelativeToView, ElementName=lbl,
                             Property=X, Factor=1, Constant=-30}"
                             RelativeLayout.YConstraint = "{ConstraintExpression Type=RelativeToView, ElementName=lbl,
                             Property=Y, Factor=1, Constant=30}"
                             RelativeLayout.WidthConstraint = "150" RelativeLayout.HeightConstraint = "100" />
                </RelativeLayout>
            </ContentView>
        </x:Array>
    </telerikPrimitives:RadSlideView.ItemsSource>
</telerikPrimitives:RadSlideView>

 

In this case everything is okay (I don't place RelativeLayout into the RadSlideVIew):

<RelativeLayout>
            <Label x:Name="lbl"
                   Text="RelativeLayout"
                   RelativeLayout.XConstraint = "{ConstraintExpression Type=RelativeToParent,
                   Property=Width, Factor=0.5, Constant=-50}"
                   RelativeLayout.YConstraint = "{ConstraintExpression Type=RelativeToParent,
                   Property=Height, Factor=0.5, Constant=-150}" />
            <BoxView Color="Blue"
                     RelativeLayout.XConstraint = "{ConstraintExpression Type=RelativeToView, ElementName=lbl,
                     Property=X, Factor=1, Constant=-30}"
                     RelativeLayout.YConstraint = "{ConstraintExpression Type=RelativeToView, ElementName=lbl,
                     Property=Y, Factor=1, Constant=30}"
                     RelativeLayout.WidthConstraint = "150" RelativeLayout.HeightConstraint = "100" />
        </RelativeLayout>

       

 

 

2 Answers, 1 is accepted

Sort by
0
Kyrylo
Top achievements
Rank 1
answered on 19 Oct 2019, 07:31 AM

I've just found workaround for this problem. The workaround is to create separate ContentView with RelativeLayout and use it in Xaml. Is it possible to do it without creating separate ContentView?

<telerikPrimitives:RadSlideView IndicatorText="○"
                                IndicatorColor="#EAFB07"
                                IndicatorFontSize="18"
                                SelectedIndicatorText="●"
                                SelectedIndicatorColor="#EAFB07"
                                IndicatorsSpacing="11"
                                ShowButtons="False">
    <telerikPrimitives:RadSlideView.ItemsSource>
 
        <x:Array Type="{x:Type ContentView}">
            <tutorialpagetest:TestView />
        </x:Array>
 
    </telerikPrimitives:RadSlideView.ItemsSource>
</telerikPrimitives:RadSlideView>
0
Didi
Telerik team
answered on 21 Oct 2019, 02:36 PM

Hello,

Thank you for the provided code and detailed explanation of the issue.

I have created a sample based on it and I reproduce the behavior on my side. It seems that you try to position the BoxView based on the label. Let me explain in details what happens: 

- the label is position correctly because the parent is the ContentView, and the view is added to the visual tree. then you have tried to position the boxview based on the label, but this label is not in the visual tree and exception occurs.

I can see that you have already found a solution for this. This is the approach you should use.

I hope I was helpful.

Regards,

Didi
Progress Telerik

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 Feedback Portal and vote to affect the priority of the items
Tags
SlideView
Asked by
Kyrylo
Top achievements
Rank 1
Answers by
Kyrylo
Top achievements
Rank 1
Didi
Telerik team
Share this question
or