I am creating a cross platform application using Xamarin Forms, However as you can see on the left the spacing in between my buttons in my android application is too much as I can not seem to reduce it. The buttons are children of a StackLayout.
Add a different spacing on each platform
<StackLayout.Spacing>
<OnPlatform x:TypeArguments="x:double" iOS="5" Android="0" WinPhone="10" />
</StackLayout.Spacing>
If accepted solution does not work for you in Xamarin.Forms (Xamarin 4.10), you can also specify the following:
<StackLayout Padding="20" Spacing="0">
...
</StackLayout>
Related
In my MAUI application I'm using webview to display my existing static html pages. But it is giving me scrollbars horizontally and vertically. I want my html page to adjust itself based on screen-size of device.
I tried to set MaximumHeightRequest & MaximumWidthRequest but it didn't worked for me. I want to have a dynamic solution for this problem.
Are you looking for this https://github.com/dotnet/maui/issues/8241. Look for #MobileDev327 comments
<ContentPage .....>
<ScrollView>
<Grid>
<Grid>
<Label Text="By default, a Grid contains one row and one column" />
</Grid>
<Grid Padding="0,30,0,0">
<WebView x:Name="jsExampleWebView" Source="Map.html"/>
</Grid>
</Grid>
</ScrollView>
Windows
Android Emulator
I am having difficulty in aligning a toolbar item to the far right on the IOS build of a Xamarin application, although, on the Android build, it works perfectly fine and aligns the toolbar item to the far right of the toolbar.
XML code for the toolbar item:
<ContentPage.ToolbarItems x:Uid="ToolbarName">
<ToolbarItem x:Name="Settings" Order="Primary" Icon="cog.png" Priority="0" Clicked="Settings_Clicked" />
</ContentPage.ToolbarItems>
IOS build toolbar:
I do not want to change the XML too much as I am worried that it will then effect the android build.
Any help on the matter would be greatly appreciated.
Thanks.
This is a known issue of the Xamarin ToolbarItems, you could try update you Xamarin Forms version to see if the issue was fixed.
A workaround would be using a NavigationPage.TitleView (source)
<ContentPage>
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" VerticalOptions="End" Spacing="10" HorizontalOptions="End">
<Image Source="cog.png">
</Image>
</StackLayout>
</NavigationPage.TitleView>
</ContentPage>
I am trying to implement Popup dialog or Dialog in Xamarin.Forms but i am unable to find any reference or document to achieve this.
I want to show view on top of current page, something like this...
Currently i am focusing on iOS in Xamarin.Forms... Any code snippet or project reference is appreciated
Popup Page Plugin for Xamarin Forms
The plugin allows you to open any page as a popup.
Nuget: https://www.nuget.org/packages/Rg.Plugins.Popup/
Unfortunately you can't Push to the ModalStack because it replaces the current page and you want to see the current page underneath.
So you have a few options here of create your own if you want complete customization or use a package such as: https://github.com/aritchie/userdialogs. They have a link to examples on that page.
Here is a quick customizable one if you want to roll your own.
<Grid IsVisible={Binding IsDialogShown}" BackgroundColor="Black" Opacity="0.7">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="500" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="1">
.. Controls in here (change this to grid or whatever you want)
</StackLayout>
</Grid>
You can take a look to popup layout in Xamarin Labs
https://forums.xamarin.com/discussion/32373/how-to-implement-a-pop-up-window-in-xamarin-forms
FormsPopup can do the trick using Xamarin Forms
We can achieve dialog like interface using PopupLayout
https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms/Controls/PopupLayout.cs
How to use :
http://forums.xamarin.com/discussion/comment/101489/#Comment_101489
Is there any way to completely remove the header in the Windows Phone 7 control toolkit ListPicker? E.g., setting the header height size = 0 or something similar?
In my app I want to remove the header in order to reduce the space taken up by the list picker. I'm going to have the default selected item in the list picker with a descriptive text instead (along with a valid value of course). I've solved that part.
Thanks in advance for any help!
Download the source from here:
http://silverlight.codeplex.com/SourceControl/changeset/changes/71382
Open up ListPickerPage.xaml (Microsoft.Phone.Controls.Toolkit -> ListPicker)
Find this section of code:
<!-- Header Title -->
<TextBlock
x:Name="HeaderTitle"
Grid.Row="0"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="{StaticResource PhoneFontSizeMedium}"
Foreground="{StaticResource PhoneForegroundBrush}" Visibility="Collapsed"
Margin="24 12 12 12">
<TextBlock.Projection>
<PlaneProjection RotationX="-90"/>
</TextBlock.Projection>
</TextBlock>
Note that the Visibility is now set to Collapsed
Then, below it, find the ListBox code
<!-- List of Items -->
<ListBox
x:Name="Picker"
Grid.Row="1"
ItemsSource="{Binding}"
Opacity="0"
toolkit:TiltEffect.IsTiltEnabled="True"
Margin="24 -24 0 0"
Tap="OnPickerTapped"/>
</Grid>
Note that I changed the margin here to -24.
Mess with it till you find the look that you need. Make sure you have your app use the DLL that is created when you build the Silverlight Toolkit project.
There could be a better way. For example, you could create your own PickerPageUri .
But, I'm not entirely sure that modifying the UI in this way to achieve another 40px of space is really worth breaking the WP7 paradigm. But whatever, your choice.
I'm creating a WP Mango app. I want to set the default page background to White, irrespective of whether Light or Dark Theme is selected, exactly like the default mail application.
I've followed this article and tried changing the default PhoneBackgroundBrush as:
(Application.Current.Resources["PhoneBackgroundBrush"]as SolidColorBrush).Color = Colors.White;
Any idea what I'm doing wrong or how to achieve that?
I messed with the sample, and simply don't recommend doing this. Do the extra work, create your own resources, and apply them yourself.
This method doesn't show updates in the designer, which will make your UI development difficult.
It also doesn't even work properly -- the background doesn't change. If you read the comments on the blog post, there are other issues with it working with other controls.
So, just do it normally - in your App.xaml (you could also do it in a seperate ResourceDictionary)
<!--Application Resources-->
<Application.Resources>
<SolidColorBrush Color="White" x:Key="WhiteBrush" />
<SolidColorBrush Color="#FFF222" x:Key="UglyYellowBrush" />
</Application.Resources>
then, on a page
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="{StaticResource UglyYellowBrush}">
... </Grid>
You could even do this quickly on all your pages using Find & Replace, provided that you never changed the name 'LayoutRoot'. If you find
<Grid x:Name="LayoutRoot" Background="Transparent">
you can replace with
<Grid x:Name="LayoutRoot" Background="{StaticResource UglyYellowBrush}">
The solution of creating your own style did not work for me. I tried setting the background to a light gray which worked in the design view but when I ran the emulator the standard black background appeared.