Syncfusion ComboBox not working in stacklayout - xamarin.forms

I'm using trial version of syncfusion for testing.
I'm tring to use comboBox in an stackLayout but it won't show. as long as it fill the whole line it works but when i try to use it in an stacklayout it stop showing.
what should i do to use comboBox within an horizontal stacklayout?
this is my xaml code
<StackLayout Orientation="Horizontal">
<Button Text="T"/>
<comboBox:SfComboBox />
</StackLayout>

You need to specify a height request, so it will "reserve space" for displaying the ComboBox.
Check this example, you can change the value of HeightRequest according to your needs.
<combobox:SfComboBox HeightRequest="40" x:Name="comboBox"/>

Related

Xamarin XCT Popup rounded Corners

is it possible to round the corners of the XCT popup?
I tried to set the BackgroundColor to transparent, and to set the body in a frame with the option CornerRadius - but this does not work as desired.
Does anyone have a tip on how to round the corners?
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="CashTracker.Views.ImagePopup"
xmlns:viewmodels="clr-namespace:CashTracker.ViewModels"
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit"
Size="300,400"
BackgroundColor="Transparent">
<Frame CornerRadius="20" HasShadow="True">
<StackLayout>
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
<Image x:Name="PopupImageSource"/>
</StackLayout>
</Frame>
</xct:Popup>
Xamarin XCT Popup
The popup should look like this - only without the white corners.
Xamarin Popup Frame
Somehow BackgroundColor was not working for Popup. Hence use the Color propperty for setting color of the Popup.
If you are using Frame in your layout, you can use Frame's CornerRadius for rounded corners (only if you are using Frame).
If you are not using Frame then you can use Xamarin Community Toolkit's CornerRadiusEffect.CornerRadius to set CornerRadius for any Layout, View or Control.
Hence for your question, it can be done by setting Popup's color as Transparent and your content's parent element must have property for corner radius and must have BackgroundColor set to White or any other Color as your Popup`s color is Transparent.
Here's the XAML
<xct:Popup ...
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit"
Size="300,400"
Color="Transparent">
<Frame CornerRadius="20" HasShadow="True">
<StackLayout>
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
</StackLayout>
</Frame>
//OR, if you don't need Frame then,
<StackLayout BackgroundColor="White" xct:CornerRadiusEffect.CornerRadius="10">
<Label Text="Aufgenommenes Foto" FontSize="Medium" HorizontalOptions="Center"/>
</StackLayout>
</xct:Popup>
There are lot of bugs in Xamarin Community Toolkit controls and views, we need to have some work-around for every control. Be it XCT's Popup, TabView, or extensions such as CornerRadius, ShadowEffect, TouchEffects, NativeAnimations, etc. The Community can't provide a single control without any bugs. But still, there are lots of useful features in XCT, hence we can only hope that the bugs are fixed, although the focus of fixing bugs if moved on to MAUI's Community Toolkit, until then we can use some work-arounds till stable and useful version of MAUI is released (considering its current status while writing this answer).

Image resizing inside a StackLayout in Xamarin.Forms

<?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="StackStuff.MainPage">
<StackLayout Orientation="Vertical">
<Image Source="image.jpg" VerticalOptions="Fill" HorizontalOptions="Fill"/>
</StackLayout>
</ContentPage>
I have a Xamarin.Forms project where I want an image to resize inside a StackLayout. I stripped it down to the minimal code above and if I resize the window, the image will only resize based off the window width. i.e. the image gets clipped off the bottom of the window if I change the height.
If I change the StackLayout's Orientation to Horizontal, I get the opposite - it'll resize based off a changing height, but not width.
If I completely remove the StackLayout and have only the image on the page, then the entire image will always be visible which is the behaviour I expected when it's inside the StackLayout.
Can anyone explain why this is? If I replace the Image with a BoxView, it'll happily resize and stay within the bounds of the StackLayout.
Thanks.
I solved this by wrapping the image in a grid:
<StackLayouenter code heret Orientation="Vertical">
<Grid>
<Image Source="image.jpg" VerticalOptions="Fill" HorizontalOptions="Fill"/>
</Grid>
</StackLayout>
I have no idea why it works but I guess that's Xamarin.Forms for you.

Horizontal and vertical scroll in Xamarin Form

I have a grid that contains many collection views with horizontal scrolling. I want to add vertical scroll because later views can not see. How Can I design? Which controls should I use for it?
You could put the Grid in a ScrollView
<ScrollView Orientation="Vertical" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid>
//...
</Grid>
</ScrollView>
contains many collection
In addition, If the content of Grid is similar , you could also put them in a ListView .

Resizing Activity Indicator in Xamarin Forms

I am trying to resize an ActivityIndicator (in Xamarin.Forms), but the Scale property does not work and the HeightRequest just crops the ActivityIndicator.
<StackLayout>
<ActivityIndicator HorizontalOptions="Center" VerticalOptions="StartAndExpand" HeightRequest="20" IsRunning="True" />
</StackLayout>
This is the result.
Any suggestions on what I might be doing wrong?
It seems sizing itself is not supported on the ActivityIndicator. In this case, scaling is your friend.
The cutting-off you see happening is because the ActivityIndicator is inside a StackLayout. Because of how a StackLayout works, it will only take up the space it needs. Since scaling doesn't necessarily make your ActivityIndicator bigger, you have two options:
Replace your StackLayout with a Grid
Give your ActivityIndicator a WidthRequest and HeightRequest that is big enough to keep your scaled ActivityIndicator
Note: Talking about iOS here. Width and height seem to work on Android
Remove HeightRequest="20", it blocks your scale property.
Code should look like this
<ActivityIndicator HorizontalOptions="Center" VerticalOptions="StartAndExpand" Scale="2" IsRunning="True" />
Now, you can scale to whatever size you want.

how to change the margin of a button on xamarin forms?

i have a issues with default margin of a button on xamarin forms. i need to take off the margin. some thought how i can make this ?? i need to use custom renderer?
I really need this to join two elements without leaving space, a label and a button.
i already try with
<Button
BackgroundColor="Fuchsia"
BorderRadius="0"
BorderWidth="0"
Text="Test"
HeightRequest="50"
WidthRequest="60"
TextColor="#333333"
x:Name="btnBack"
Margin="0"
VerticalOptions="Start"
HorizontalOptions="Start" />
but this not work for me, nothing happened.
other guys says that making a custom renderer maybe will work.
What are you using to lay out the label and the button? If StackLayout you may need to set the StackLayout Spacing property to 0 to remove the gap between the label and the button. If Grid look at RowSpacing and ColumnSpacing properties.
If you want to change margins dynamically, you would write something like this in C#
button.margin = new thickness(0,0,0,0);
This would make the margins of the button 0.
You would potentially do this for all elements with a thickness to change that issue.

Resources