paxamit
Topic Author
Posts: 1
Joined: 04 Apr 2017, 13:36

Gamepad icons in text

09 Jul 2018, 13:17

Is there any way to have gamepad icon inside textblock? ( like " Press (A) to start" , where (A) is icon )
Only way i found is adding gamepad icons to font.
 
mingingmingler
Posts: 28
Joined: 15 Jan 2018, 00:03

Re: Gamepad icons in text

09 Jul 2018, 20:25

This is possible using inlines, which are supported, but non-text elements require WPF's InlineUIContainer, which isn't supported.

Having the buttons as font glyphs may provide the most flexibility for you in terms of localisation and compatibility of text rendering.

Since it's only a single line of text, if you're not localising you can simply split the text up into two TextBlocks, with the icon in the middle, inside a horizontally oriented StackPanel. Even if you are localising, I've seen projects which use two separate localised strings for the left and right parts of this very use case.

Another solution, which is the same idea in principle, would be to have a converter split your input string into a list of objects, and provide this list as a source to an ItemsControl where they will be rendered inside a StackPanel as TextBlocks or Images/etc. This is quite a workaround, but it would work fine with localisation.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Gamepad icons in text

19 Jul 2018, 02:12

Until we add support for InlineUIContainer the available options as @mingingmingler perfectly explained are:
- using a font with icon glyphs, or
- using a Horizontal StackPanel or WrapPanel with several TextBlocks and Images/Shapes.

The second one allows you to introduce colored images/shapes.

Who is online

Users browsing this forum: No registered users and 98 guests