<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Xamarin on David Marchbanks</title><link>https://davidmarchbanks.dev/en/tags/xamarin/</link><description>Recent content in Xamarin on David Marchbanks</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 01 Jul 2019 01:32:06 +0000</lastBuildDate><atom:link href="https://davidmarchbanks.dev/en/tags/xamarin/index.xml" rel="self" type="application/rss+xml"/><item><title>Easy Circle Image in Xamarin without a plugin</title><link>https://davidmarchbanks.dev/en/posts/easy-circle-image-in-xamarin-without-a-plugin/</link><pubDate>Mon, 01 Jul 2019 01:32:06 +0000</pubDate><guid>https://davidmarchbanks.dev/en/posts/easy-circle-image-in-xamarin-without-a-plugin/</guid><description>&lt;p>So &lt;a href="https://montemagno.com/">James Montemagno&lt;/a> has written a plugin a long while back that provides an easy method for writing images to XAML. The only down side to this is that you have to add a namespace and nuget package.&lt;/p>
&lt;p>So while watching &lt;a href="https://kymphillpotts.com/">Kym Phillpots&lt;/a> on Twitch, I learned a new way of providing circular images without a plugin. It&amp;rsquo;s super easy!&lt;/p>
&lt;p>So to start out we are going to wrap an image in a frame. Then adjust our corner radius to the appropriate radius ( half of your expected image size ). By default, the image is likely to bleed off the frame or some other unwarranted result.&lt;/p></description></item><item><title>Write your own Custom Controls for Xamarin.Forms</title><link>https://davidmarchbanks.dev/en/posts/write-your-own-custom-controls-for-xamarin-forms/</link><pubDate>Thu, 23 May 2019 01:06:18 +0000</pubDate><guid>https://davidmarchbanks.dev/en/posts/write-your-own-custom-controls-for-xamarin-forms/</guid><description>&lt;p>So why would you need to write a custom control for Xamarin? Does it have a purpose other than wrapping native controls that don&amp;rsquo;t exist in Xamarin? Why yes, it does serve a good purpose. I often will write a component to avoid having to copy and paste XAML repeatedly.&lt;/p>
&lt;h2 id="how-do-we-create-one">How do we create one?&lt;/h2>
&lt;p>I am going to assume you already have a project started in this post. I often create a directory/namespace called Controls in my PCL for this purpose. In any case, right click in your solution in Visual Studio&amp;rsquo;s PCL project and click Add, and then New Item.&lt;/p></description></item><item><title>Writing XAML Value Converters for Xamarin Forms</title><link>https://davidmarchbanks.dev/en/posts/writing-xaml-value-converters-for-xamarin-forms/</link><pubDate>Tue, 23 Apr 2019 02:58:00 +0000</pubDate><guid>https://davidmarchbanks.dev/en/posts/writing-xaml-value-converters-for-xamarin-forms/</guid><description>&lt;h2 id="explanation">Explanation&lt;/h2>
&lt;p>XAML isn&amp;rsquo;t perfect. It is often missing some tools that honestly should just be a party of the set. For example, express if a value is null or not null.&lt;/p>
&lt;p>What we will want to use is the IValueConverter interface. This interface has two methods defined:object Convert&lt;/p>
&lt;pre tabindex="0">&lt;code>object Convert(object value, Type targetType, object parameter, CultureInfo culture);&lt;/code>&lt;/pre>&lt;pre tabindex="0">&lt;code>object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);&lt;/code>&lt;/pre>&lt;p>These two methods are used to convert a value from one type to another. The first method is called to convert your base value. The second one is if you have two way binding, to convert it back. This is not always necessary unless you have a specific use case that can be converted from one value to another, such as Hex color to Color object and vice versa.&lt;/p></description></item></channel></rss>