Gamepad icons in text
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.
Only way i found is adding gamepad icons to font.
- mingingmingler
- Posts: 28
- Joined:
Re: Gamepad icons in text
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.
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.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Gamepad icons in text
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.
- 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