Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

CarouselPage binding

$
0
0

I haven't used the CarouselPage before and I cannot get the binding for the children pages to work. I have something like this:

`    <?xml version="1.0" encoding="utf-8" ?>
<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:JaaTyrePal;assembly=JaaTyrePal"
             xmlns:iconize="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize"
             x:Class="JaaTyrePal.HomePage"
             NavigationPage.HasNavigationBar="false">
    <ContentPage x:Name="Page1" BackgroundColor="Black"  >
        <Label Grid.Row="0" Grid.Column="1" Text="{Binding Temp}" Style="{StaticResource GaugeLabel}"/>

    </ContentPage>
    <ContentPage x:Name="Page2" BackgroundColor="Black" Title="Right Tyres">
         <Label Grid.Row="0" Grid.Column="1" Text="{Binding TempB}" Style="{StaticResource GaugeLabel}"/>
    </ContentPage>
</CarouselPage>`

And my simple ViewModel:
`

            public HomePageModel(MasterParameterContainer masterContainer)
            {
                Temp = 2.3;
            }

            double _temp;
            double Temp
            {
                get
                {
                    return _temp;
                }
                set
                {
                    _temp = value;
                    RaisePropertyChanged();
                }

`

I cant get the binding to work for ContentPages, I even tried the following in the code behind:

`protected override void OnBindingContextChanged()
        {
            Page1.BindingContext = BindingContext;
            Page2.BindingContext = BindingContext;
            base.OnBindingContextChanged();
        }`

What am I doing wrong here?


Viewing all articles
Browse latest Browse all 204402

Trending Articles