I'm creating a chat in WPF and I'm trying to make user can send emoji. The user writes a message in a TextBox
and he can open menu with emoji and choose some. A probem is that emoji are not colored, but they are black and white.
I tried to use emoji.wpf
, but it works only in RichTextBox
(I need buttons
and TextBox
too) and the emoji are rendering very slowly. Somewere I read that the only solution is to insert emoji as pictures. Is it true or it exists some better solution? It would be advisable to have emoji as unicode characters, not pictures.
Sorry for my english, I'm from Czech Republic.
I wrote Emoji.Wpf; here are a few comments:
There is an Image
class that can be trivially used in a Button
. See for instance the font viewer sample which uses simple XAML like this: <emoji:Image Width="44" Height="44" Text="{Binding UnicodeText}"/>
It is quite difficult to subclass TextBox
for colour emoji because it only supports a single font and font style; overriding the rendering code seems difficult and I am not skilled enough to do it.
Here is what the font viewer looks like:
I found a very easy and great method!
Just add a Nuget package named "Emoji.Wpf" and use it as below:
<Window ...
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
...>
...
<emoji:TextBlock FontSize="24" Text="💖😁🐨🐱🐉👩🏿👩🏻👦🏽"/>
...
</Window>
And it works well for my WPF app.
More information in it's project site:
https://github.com/samhocevar/emoji.wpf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With