https://github.com/egbakou/emojisinxamarinforms
Use of Emojis in Xamarin.Forms π€π€π¨ π€Ήβ
https://github.com/egbakou/emojisinxamarinforms
android emojis emojis-in-xaml ios xamarin-forms xaml
Last synced: 7 months ago
JSON representation
Use of Emojis in Xamarin.Forms π€π€π¨ π€Ήβ
- Host: GitHub
- URL: https://github.com/egbakou/emojisinxamarinforms
- Owner: egbakou
- Created: 2019-05-09T07:29:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-15T09:59:03.000Z (over 6 years ago)
- Last Synced: 2025-03-21T11:50:33.500Z (7 months ago)
- Topics: android, emojis, emojis-in-xaml, ios, xamarin-forms, xaml
- Language: C#
- Homepage: https://lioncoding.com/2019/05/04/2019-05-04-utiliser-des-emojis-dans-xamarin-forms/
- Size: 521 KB
- Stars: 15
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Use of Emoji in Xamarin.Forms π€π€π¨ π€Ήβ

Emoji is represented by a single Unicode character or a specific sequence of Unicode characters.
For example , π€ is represented by `U+1F914`.
The full list of emojis can be found [here](http://www.unicode.org/emoji/charts/full-emoji-list.html).
## Static use in XAML
Since XAML is an XML-based markup language, we have to use XML escape character `` and we have to replace `U+` prefix by `x` for each part of our emoji :
`U+1F914` become `π€` :
```xaml
```
## Use Binding
if you want to use Data Binding to display emoji, letβs define a class that will represent emoji:
```csharp
using System;
using System.Text;namespace EmojiInXaml.Models
{
///
/// Emoji class.
///
public class Emoji
{
readonly int[] codes;public Emoji(int[] codes)
{
this.codes = codes;
}public Emoji(int code)
{
codes = new int[] { code };
}public override string ToString()
{
if (codes == null)
return string.Empty;var sb = new StringBuilder(codes.Length);
foreach (var code in codes)
sb.Append(Char.ConvertFromUtf32(code));return sb.ToString();
}
}
}
```It requires a single Unicode character or sequence of characters as an input and simply overrides the `ToString` . Please note that `U+` prefix should be replaced with `0x` to specify hexadecimal notation.
**Example of usage**
// person biking => http://www.unicode.org/emoji/charts/full-emoji-list.html#1f6b4
```csharp
string bikingEmoji = new Emoji(0x1F6B4).ToString(); // π΄
``````xaml
```