How to create a Tokenizing Control for UWP as known from Outlook when using To, Cc and Bcc - xaml

There is a great article about how to write a Tokenizing Control for WPF here: Tokenizing control – convert text to tokens
But how is this accomplished in an UWP App? The Windows 10 UWP Mail client does this just fine, so I know that it is possible. But how?
Tokenizing is super useful for To/CC/BCC input areas, as we know it from Outlook and lately from the Windows 10 UWP Mail client.
I suspect that RichTextBlock or maybe RichEditBox combined with AutoSuggestBox could be part of the answer, but in the WPF example above FlowDocument is used and FlowDocumet is not supported in UWP.

I haven't looked at their code. They likely have a text input control of their own, but you could achieve a fairly similar and possibly acceptable effect by putting (Rich)TextBox and "token" elements in a WrapPanel. You won't be able to easily select all text, but you could get clickable token elements.
Otherwise - you might have a bit of work figuring out completely hand-crafted input and rendering.

Related

Xamarin Forms FontIcon Upper Bitplane XAML Escape Character

I'm trying to use MaterialDesignIcons in a Xamarin Forms Shell app. The latest version of this font encodes all of the glyphs in the upper bit planes (see this old StackOverflow question about that).
The problem I have is that I don't know how to identify the proper XAML escape sequence for upper bit plane glyphs. For example, \uf30c in C# code translates to  in XAML. But I don't know how to translate an upper bit plane value (e.g. \U000f0706) to the correct XAML escape sequence.
I thought I'd just use a binding to code instead, but this is blocked by an open bug. There's a workaround in that GitHub issue, but it doesn't seem to work for a Tab Bar Icon (which is where I'm trying to use it).
TL;DR - how to I write \U000f0706 in XAML?

Curve Texblock in XAML / W8.1 throughTemplate?

Is it possible to access the TextBlock Template to change the border and make it curved?
I tried editing the Template through Blend but with no success.
I'm trying to achieve something like this (couldn't get that given solution working):
Curve TextBlock in Windows 8
I'm trying to do this in C#/XAML - WINRT (Windows 8.1)
I don't think a TextBlock has a template you could modify. It's probably just some parameters used to tell DirectWrite what text to render and with what properties. The easiest way to solve it is when your text is constant to just break it apart into multiple single letter TextBlocks and lay them out on a path using Blend or Illustrator. If don't control what text can show up on the path - you'd have to code up the layout algorithm. Chris's link seems like a good place to start.
There isn't a clean way to do this directly in Xaml. Like Filip says, you can approach it by breaking the letters apart. That can work well for long sentences with small letters, but can be pretty chunky with large or connected letters. If you need smoother rendering then you can interop to Direct2D.
MSDN has a Direct2D animated text on a path sample which you could combine with the XAML SurfaceImageSource DirectX interop sample

How to create switchable multi-language pdf form?

I want to create a pdf form for two language (Chinese/English) UI, and there's a button(s) or somethings on the form for language switch, is there anyway can make it? and how to do?
thanks!
Thanks for all reply!
Actually I got a sample like this,
PDF Sample
there're two checkbox on the top-left of the form, one is for English UI, the other is Chinese, I just want to know how to make PDF like that sample? (and I don't see any layers on the sample...)
thx
mkl's comment (which he should turn into a full answer, really) already hinted at the option to use different page templates residing in the same file.
Another option you could explore is this:
put the two language versions into 2 different layers (or 'optional content groups' in PDF parlance)
make the visibility of the two layers toggeable
let the user activate that layer which he/she needs.
Layer activation can be handled through normal Acrobat Reader user interface elements.
The layer switching can be made accessible via a "button" on the PDF page too -- but that requires additional JavaScript to be embedded in the PDF (something many people are not particularly keen about).
As Kurt proposed, I make my comment on Frank's answer an answer in its own right:
Actually there is a pdf feature seldomly used nowerdays, page
templates. Thus, those two forms can reside in the same file in
different page templates, and based on some initially present buttons
("English version", ...) the desired form is spawned.
Unfortunately I don't know how to create page templates using some easy-to-use tool, I only came a cross them in the context of integrated PDF signatures (depending on the signature type, page template instantiation is a document change not breaking the signature) and tested them with low-level tools.
Essentially page templates are PDF objects just like page dictionaries of the normal pages, they are not XFA stuff. They merely are not referenced in the pages tree but instead in the name tree.
There is a JavaScript command which creates a visible page based on such a template --- I don't know which anymore; I may be able to find out when I'm back in office next week. This command would have to be bound to the inital language selection button in the file.
The problem will be in switching the static text - PDF does not allow this.
If I were you, I would split the document into two identical forms in the respective languages. You can use bookmarks and links on the first page to navigate to the right part of the document.
Note that it is possible to assign the same field names to the Enlgish/Chinese versions of your fields. This will make it easier to process the submitted form data because the process path would be independent of the chosen language. It will also simplify any JavaScript (validation, summing, etc.) you plan to add.

How to measure text in a RichTextBox in Silverlight

I want to get the height necessary to display the full text in my RichTextBox (when the text extends beyond the set height of the control).
Reminder: Silverlight has no handy TextRenderer.MeasureText like WPF does, nor any other apparent way to measure text.
Doesn't seem like there's any way to do this. I've seen mention of people measuring text of a single font (not mixed as in my RichTextBox) by creating a TextBlock and getting it's Width. Even this doesn't work - it's perfect for some fonts and inconsistent for others.
My app is occasionally connected, so I can't call the server.
As you say, I don't think there's a good way to do this in Silverlight today. There are some functions available in the Document Toolkit by First Floor Software, however those are geared towards working with XPS documents. I'm not sure what you're trying to do, however in Silverlight 5 the RichTextBox does come with the ability to "overflow" text into multiple other RichTextBoxes when the first one cannot display all of the data. This allows you to more easily create a multi-column text layout.
Document Toolkit: http://firstfloorsoftware.com/documenttoolkit
SL5 Video: http://www.silverlight.net/learn/videos/all/silverlight-5-multi-column-linked-text/
SL5 Blog Post: http://10rem.net/blog/2011/04/13/silverlight-5-advancements-in-text

Silverlight 4 RichtTextBox - how do I get the text without the formatting?

How do I get the text out of a Silverlight 4 RichTextBox without the formatting? I know the Xaml property will give me the XAML but I just want the text.
This is a little late, but I will post anyway. There is a trick that involves selecting all the text in code and then accessing the Text propety of the TextSelection object. Like so:
myRichTextBox.SelectAll();
var plainText = myRichTextBox.Selection.Text;
I am using it in my apps and although it is not the prettiest solution, it works. Found it here:
http://forums.silverlight.net/forums/p/184560/422007.aspx
If you just want text, why not use TextBox instead?
There are various third-party components that support this kind of functionality (unfortunately paid). For example, Telerik's RadRichTextBox supports both highlighting and exporting rich text content as plain text, latter trough component called TxtFormatProvider.