HorusSoftwareUY / Xamarin.Forms.Skeleton

The new loading approach for cool apps in Xamarin Forms
MIT License
450 stars 52 forks source link

Skeleton.BackgroundColor not working #23

Open Vladovi opened 3 years ago

Vladovi commented 3 years ago

Hi, for some reason it does not work for me Skeleton.BackgroundColor, problem with element label, below is my code, please point out my mistakes.

Xaml: `<ListView x:Name="list" ItemsSource="{Binding Model}" RowHeight="450" SeparatorVisibility="None" VerticalScrollBarVisibility="Never" IsPullToRefreshEnabled="True" IsRefreshing="{Binding IsRefreshing}" RefreshCommand="{Binding Command}" SelectionMode="None" ItemAppearing="List_ItemAppearing" skeleton:Skeleton.IsParent="True" skeleton:Skeleton.IsBusy="{Binding IsBusy}" skeleton:Skeleton.Animation="{skeleton:DefaultAnimation Fade}">

       <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid Padding="0, 5"> 
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="5*"/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="2*"/>
                        </Grid.ColumnDefinitions>
                       <imageRender:ImageRender Source="{Binding Image, Converter= {StaticResource Key=ByteArrayConverter}}"
                                                 WidthRequest="40"
                                                 HeightRequest="40"
                                                 HorizontalOptions="CenterAndExpand"
                                                 VerticalOptions="CenterAndExpand"
                                                 Aspect="AspectFill"
                                                 BackgroundColor="Black"
                                                 skeleton:Skeleton.IsBusy="{Binding IsBusy}"
                                                 skeleton:Skeleton.BackgroundColor="Black">
                        </imageRender:ImageRender>

                        <Label FontSize="Large"
                               Grid.Column="1"
                               VerticalOptions="Center"
                               Margin="5"
                               Visual="Material"
                               skeleton:Skeleton.IsBusy="{Binding IsBusy}"
                           skeleton:Skeleton.BackgroundColor="Black">
                            <Label.FormattedText>
                                <FormattedString>
                                    <Span Text="{Binding Model1.Text}">
                                        <Span.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding BindingContext.NavigateToProfileCommand,
                                                                            Source={x:Reference Name=list}}"
                                                                    CommandParameter="{Binding Command}"
                                                                    NumberOfTapsRequired="1"/>
                                        </Span.GestureRecognizers>
                                    </Span>
                                </FormattedString>
                            </Label.FormattedText>
                        </Label>
                       .........................
                     </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>`

ViewModel:

void Skeleton()
        {
            Model = new ObservableCollection<Model>();
            IsBusy = true;
            var model1 = new Model1()
            {
                Text = "xxxxxxxxxx",
                Image = null
            };
            var model = new Model()
            {
                Image = null,
                Model1 = model1

            };
            for (int i = 0; i < 5; i++)
            {
                Model.Add(model);
            }
        }
ghost commented 3 years ago

I have the same issue. I tried implementing it on BindableLayout.DataTemplate and it won't work. I moved it to a control without any templates and it works fine so maybe try that for now. You can use a value converter and convert IsBusy == true to black or do it in the setter of IsBusy. VC is cleaner imo

Saccomani commented 3 years ago

same issue here...in XF 5