xamarin.forms - Margin to a Image in Xamarin Forms


Question: 

I have an image on my Xamarin.Forms. I want to add some margin from Top.

Form.XAML:-

<ContentPage.Content>
    <Grid>
        <Image x:Name="image" />
    </Grid>
</ContentPage.Content>"

Form.XAML.cs:-

image.Source = ImageSource.FromFile (Height > Width ? "portrait.jpg" : "landscape.jpg");



1 Answer: 

The current stable version of Xamarin.Forms, 2.2.0.31 supports the Margin property. It accepts a "Thickness" object which specifies the left, top, right and bottom sizes you want.

In XAML, the standard value converter is applied, which means you can specify Margin as one of these:

  • "10,20,30,40" - all the sides specifeid in order left, top, right, bottom
  • "10,20" - 10 units applied to left and right, 20 to top and bottom. Same as "10,20,10,20"
  • "10" - margin of 10 units is applied to all sides, same as "10,10,10,10"

More documentation is available here Margins and Padding

 

More Articles


c# - WindowsForm app with wpf windows is not working on other computers

I'm new to WPF and c# programming,i have built a winform app with a database and some wpf forms.wpf forms contain some background images and componentone tab controls.To add wpf forms:i added a wpf user control and modified its code as a window.in that case i m unable to put background images from u

android - How to get a progress bar under the ActionBar in Material Design?

The Material Design specifications for Progress and activity specifically show in several areas a horizontal progress indicator of only a few pixels (dips) thick below whatever it is we are calling the ActionBar these days (probably Toolbar).However, I don't see any way to actually implement that po

wpf - Canvas control is not available in Windows form application?

WPF Canvas control is not available in Windows form application. Am using Visual Studio 2010. Framework 4.0. Is there way to add these controls to VS2010 toolbox?


material design - android lollipop toolbar: how to hide/show the toolbar while scrolling?

I'm using the new toolbar widget introduced in the appcompat / support-v7. I would like to hide/show the toolbar depending on if the user is scrolling up/down the page, just like in the new Google's playstore app or NewsStand app. Is there something built into the toolbar widget for this or should I

Android: pin TabLayout to top of Scrollview

I was looking at the twitter app on my phone.You can see that when a user scrolls up, the tabLayout actually just pins itself onto the bottom of the toolbar nicely and does not move at all.I thought maybe they did it by just putting all of the top part of the app (the profile picture, the profile wa

c# - ASP.NET Chart Control and Databinding to multiple Series

I am working with the ASP.NET chart control and I am using the following code to databind data to the chart control. The chart has three series on it: Series1, Series2 and Series3. The problem that I am having with the code below is that it only seems to bind to the first series so that when the ch


How to disable version control in phpstorm?

I am playing around with phpstorm and somehow I activated version control. I don't need it. Now all my tabs are different: orange text on gray background. All files in the file view are orange. How do I disable version control?

Keras autoencoder outputting wrong shape

I'm trying to build a deep convolutional autoencoder in Keras, but it keeps outputting the wrong shape.Code: def build_network(input_shape): input_input = Input(shape=input_shape) #Encode x = Conv2D(16, (3, 3), activation='relu', padding = 'same')(input_input) x = MaxPooling2D((2, 2), p

phpStorm show changed/modififed files in project view

After moving from Zend Studio (ZS) to phpStorm I am starting to miss the way that ZS used to show changed files and display more than one project at once. E.g: notice how the IndexController.php shows that this has been modified. Is there anyway to do this with phpStorm?

AttributeError: 'NoneType' object has no attribute '_inbound_nodes' in Autoencoders in Keras

I am not able to solve the following error, please accept my apologies if it sounds naive, I am very new to Keras.The output of the encoder is actually a complex value, so each output is real and imaginary part, input_h1 is also a complex value with real and imaginary parts represented as a vector.