xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.59k stars 474 forks source link

[Bug] [MauiCompat] CameraView #1890

Open mikara89 opened 2 years ago

mikara89 commented 2 years ago

Description

CameraView does not change view dimensions. FillAndExpend and also if I set RequiredWidth and RequiredHeight CameraView stays the same. CameraView when Width and Height are check in debug values are good but preview on screen still 1/3 of screen.

screenshot

 <Grid>
        <Grid RowDefinitions="1*,3*,1*">
            <xct:CameraView           
                    x:Name="cameraView"
                    CaptureMode="Photo"
                    BackgroundColor="Transparent"
                    Grid.Row="0" Grid.RowSpan="3"                
             />
            <Grid
                Grid.Row="0"
                BackgroundColor="#aa000000">
                    <Label  
                    x:Name="txtLable" 
                    Grid.Row="2" Text="Top text..." 
                    HorizontalOptions="Center" 
                    VerticalOptions="Center" 
                    TextColor="White" />
                </Grid>

                <Grid
                    Grid.Row="3"
                    BackgroundColor="#aa000000"
                    Padding="20"
                    ColumnDefinitions="Auto,*,Auto">

                    <Image 
                        Grid.Column="0"
                        x:Name="imageDispley" 
                        BackgroundColor="Red" 
                        WidthRequest="80" 
                        HeightRequest="100"/>
                    <Image 
                        Grid.Column="1"
                        x:Name="image2Displey" 
                        BackgroundColor="Red" 
                        WidthRequest="80" 
                        HeightRequest="100"/>

                    <Button Text="💡" 
                        Grid.Column="2" 
                        BackgroundColor="#aa000000"
                        CornerRadius="8"
                        BorderColor="Black" 

                        Clicked="Button_Clicked" />
                </Grid>
            </Grid>

            <!--<Grid Grid.Row="0"
              BackgroundColor="Black" 
              Opacity="0.8" IsVisible="{Binding Source={x:Reference mainPage},
                                Path=IsPhotoTaking}"
              Grid.RowSpan="3">
                <ActivityIndicator
                IsRunning="{Binding Source={x:Reference mainPage},
                                Path=IsPhotoTaking}" />
            </Grid>-->

        </Grid>

Steps to Reproduce

  1. Make simple Maui.net
  2. Add Xamarin.CommunityToolkit.MauiCompat
  3. Add CameraView To fill screen

Expected Behavior

CameraView in Xamerin fill screen with no problem

Actual Behavior

CameraView in MAUI.net does not fill screen.

Basic Information

Version with issue: >=2.0.2-preview1013 Last known good version: N/A IDE: Visual studio 2022 Platform Target Frameworks: iOS: / Android: 31 UWP: / Android Support Library Version: Nuget Packages: Xamarin.CommunityToolkit.MauiCompat Affected Devices: /

zjoerg commented 1 year ago

You can try to work around this issue by applying a negative margin to the CameraView control on the right and bottom side. In your case, setting the margin on the right to -2 * Width of the page, should strech the control to the expected size. Do it for Height accordingly.