Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Animate ContentView from XAML into XAML ContentPage RelativeLayout

$
0
0

I am in a situation where I need to animate in a custom control in the form of a ContentView to cover (mostly) the relative layout main view. My problem is I am having trouble getting the ContentView to show up in the RelativeLayout.

My main layout is:

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ToGoTechnologies.Mobile.HomePage">
    <ContentPage.Content>
        <RelativeLayout x:Name="rlMain" BackgroundColor="Blue">
        <Button x:Name="btnRewards" Clicked="ShowRewards" Text="Rewards" HorizontalOptions="CenterAndExpand"></Button>
        </RelativeLayout>
    </ContentPage.Content>
</ContentPage>

In my click handler I have tried:
public void ShowRewards(object sender, EventArgs args) {
            //_mainLayout.Children.Add (new RewardsView ());
            RewardsView rv = new RewardsView ();
            rlMain.Children.Add (new RewardsView (), 
                Constraint.RelativeToParent(p => (this.Width / 2) - (rv.WidthRequest / 2)),
                Constraint.RelativeToParent(p => (this.Height / 2) - (rv.HeightRequest / 2)),
                Constraint.RelativeToParent(p => rv.WidthRequest),
                Constraint.RelativeToParent(p => rv.HeightRequest));
        }

Nothing happens when my button is clicked. Any help or a pointer to a nice post about using ContentViews would be great.

Thanks


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>