Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Tips and Tricks

$
0
0

Does anyone have any tips and tricks for Xamarin.Forms?

I Know there's a full set of controls Here, does anyone else want to post what they've been working on?

Here's a code snippet I wrote to create a bindable property when I extend a Xamarin.Forms control:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>bprop</Title>
      <Author>Microsoft Corporation</Author>
      <Description>Code snippet for an automatically implemented $name$Property
Language Version: C# 3.0 or higher</Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>bprop</Shortcut>
    </Header>
    <Snippet>
      <Declarations>
        <Literal Editable="true">
          <ID>name</ID>
          <ToolTip>name</ToolTip>
          <Default>name</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>owner</ID>
          <ToolTip>owner</ToolTip>
          <Default>Owner</Default>
          <Function>
          </Function>
        </Literal>
        <Literal Editable="true">
          <ID>type</ID>
          <ToolTip>type</ToolTip>
          <Default>Type</Default>
          <Function>
          </Function>
        </Literal>
      </Declarations>
      <Code Language="csharp"><![CDATA[public static readonly BindableProperty $name$Property = BindableProperty.Create<$owner$,$type$>(p => p.$name$, default($type$));

public $type$ $name$
{
    get { return ($type$)GetValue($name$Property); }
    set { SetValue($name$Property, value); }
}$end$]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

This works similar to using "prop" and "ctor" but uses "bprop" as the keyword.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>