Relative Layout bug inside RadSlideView

3 posts, 0 answers
  1. Kyrylo
    Kyrylo avatar
    9 posts
    Member since:
    Oct 2019

    Posted 19 Oct 2019 Link to this post

    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. Kyrylo
    Kyrylo avatar
    9 posts
    Member since:
    Oct 2019

    Posted 19 Oct 2019 Link to this post

    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>
  3. Didi
    Admin
    Didi avatar
    359 posts

    Posted 21 Oct 2019 Link to this post

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