Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Impossible to make the heigth will the screen when hosting the CarouselView in a ListView #29

Open
mfalk118 opened this issue May 8, 2017 · 0 comments

Comments

@mfalk118
Copy link

mfalk118 commented May 8, 2017

Maybe i am doing it wrong, but i have the below XAML, and i cannot get the CarouselView show more than 2 lines (Except for setting an explicit Height om the CarouselView it self. Which i would like to avoid.

Except from the Height issue it is working as expected

Any help would be greatly appreciated:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.Views.DevicesCarouselPage"
Title="{Binding Title}"
xmlns:controls="clr-namespace:App.Controls;assembly=VisionPeople.TermoService.App"
xmlns:ValueConverters="clr-namespace:App.ValueConverters;assembly=VisionPeople.TermoService.App"
xmlns:cv="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
x:Name="ThisPage"

<ContentPage.Resources>
    <ResourceDictionary>
        <ValueConverters:BooleanNegationConverter x:Key="not" />
    </ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>


    <ListView ItemsSource="{Binding Devices}" RefreshCommand="{Binding LoadDevicesCommand}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
            IsPullToRefreshEnabled="true"
            IsRefreshing="{Binding IsBusy, Mode=OneWay}"
            CachingStrategy="RecycleElement"
            HasUnevenRows="True" 
                  ItemSelected="ListView_ItemSelected"
                  x:Name="ItemsListView"
                  >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <StackLayout>
                        <cv:CarouselView ItemsSource="{Binding Devices}" Position="{Binding Position, Mode=TwoWay}">
                            <cv:CarouselView.ItemTemplate>
                                <DataTemplate>

                                    <StackLayout Padding="10" >
                                        <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
                                            <controls:ImageIndicator SelectedIndicator="App.Images.IndicatorSelected.png" UnselectedIndicator="App.Images.IndicatorUnSelected.png" Progress="{Binding SignalStrength}" IndicatorHeight="16" IndicatorWidth="5" HorizontalOptions="Start" Margin="0,0,2,0" />
                                            <Label Text="{Binding SignalStrength}" HorizontalOptions="Start" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" />

                                            <Label Text="{Binding Description}" HorizontalOptions="CenterAndExpand"
                   LineBreakMode="NoWrap"
                   Style="{DynamicResource ListItemTextStyle}"
                   FontSize="16"/>
                                            <Label Text="{Binding Voltage}" HorizontalOptions="End"
                   LineBreakMode="NoWrap"
                   Style="{DynamicResource ListItemTextStyle}"
                   FontSize="16"/>
                                        </StackLayout>

                                        <Label Text="{Binding Temperature , StringFormat='{0:N1}°c'}" HorizontalOptions="Center"
                   LineBreakMode="NoWrap"
                   Style="{DynamicResource ListItemDetailTextStyle}"
                   FontSize="50"/>


                                        <Label Text="{Binding DataLastReceived , StringFormat='{0:f}'}" HorizontalOptions="Center"
                   LineBreakMode="NoWrap"
                   Style="{DynamicResource ListItemDetailTextStyle}"
                   FontSize="13"/>

                                        <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                                            <Image Source="{Binding BindingContext.Image, Source={x:Reference Name=ThisPage}}" x:Name="img" HeightRequest="20"  />
                                            <Label Text="{Binding Humidity , StringFormat='{0:N0}%'}" HorizontalOptions="Center"
                   LineBreakMode="NoWrap"
                   Style="{DynamicResource ListItemDetailTextStyle}"
                   FontSize="25"/>
                                        </StackLayout>
                                        <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                                            <Label Text="{Binding Voltage, StringFormat='{0:N2}V'}">
                                                <Label.Triggers>
                                                    <DataTrigger TargetType="Label" 
                                        Binding="{Binding BatteryIsLow}" Value="true">
                                                        <Setter Property="TextColor" Value="Red"  />
                                                    </DataTrigger>
                                                </Label.Triggers>
                                            </Label>
                                            <Label Text="{Binding BindingContext.DeviceChargingText, Source={x:Reference Name=ThisPage}}" IsVisible="{Binding Charging}" />
                                        </StackLayout>
                                    </StackLayout>

                                </DataTemplate>
                            </cv:CarouselView.ItemTemplate>
                        </cv:CarouselView>
                        <controls:CarouselIndicators x:Name="indicator" IndicatorHeight="16" IndicatorWidth="16" UnselectedIndicator="App.Images.unselected_circle.png" SelectedIndicator="App.Images.selected_circle.png" ItemsSource="{Binding Devices}" Position="{Binding Position}" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage.Content>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant