Most efficient XAML UI element for dumping "standard output" - xaml

As per the title, what is the most efficient way to make use available XAML UI elements to display a lot of [selectable, non-modifiable] texts being appended regularly? Think of dumping out logging information or big HTML page as they are downloaded.
The TextBox does not seem to be very efficient since the only way to change the text is to set its Text property which is a Platform::String. There is no efficient way to append Platform::String repeatedly since I believe that the Platform::String(const wchar_t *) constructor copies the input string internally so even if I try to use string buffer, it doesn't help.
As for the other text control RichEditBox, I have no idea how to use it within a DataTemplate. (I need the control to be elements of a ListView.)

You can display the logs as items of a ListView or ItemsControl and display each as simple TextBlock with selectability:
<TextBlock IsTextSelectionEnabled="True" ... />
This is the most efficient approach you can get, as the list provides virtualization and TextBlock has minimal overhead as compared to TextBlock and RichEditBox and is read-only.

Related

xaml automatic align of a textbox inside a RelativePanel

I have a TextBox inside a RelativePanel in a universal Win App in C# (XAML/vs2015).
I want the textbox to be always on the right end of the panel, even when the form size changes.
Please tell me how to do that
thank you
Well since the generic answer did the trick without needing any further detail, might as well enter it as an answer so other viewers know you got sorted and skip the question.
Since it's a child of the RelativePanel you need to supply the declaration to the element, in this case TextBox using the bool property set to true of;
RelativePanel.AlignRightWithPanel="True"
Glad you got a remedy, have a great weekend!

How to Remove Extra Space Around TextBlock

I have the following set up for my TextBlock
<TextBox x:Name="SearchTextBlock" InputScope="Search" Opacity="0.999"
Height="Auto" VerticalAlignment="Top"
BorderBrush="{StaticResource ThemeBrush}" BorderThickness="8" />
which yields
But extra space remains around the TextBlock. How might I remove this? Do I need to create a style or can this be done within the TextBlock tag itself?
From the Designer right click on the TextBox and select Edit Template -> Edit a Copy
Choose where do you want to save it and choose it's Key
And then analyzing the code generated you see Margin="{StaticResource PhoneTouchTargetOverhang}"
witch you can play with until you like the result.
TextBox has a theme style applied to it. Things like margin and padding should be fairly consistent between themes. The best way I've found to "override" the style of something (including a TextBox) is the copy the style resource and tweak it. This is easily done with the Document Outline window.
First, make sure the Document Outline window is visible. This can be done with Ctrl+W,U if you use the Visual C# keyboard thread. Or, View\Other Windows\Document Outline.
Next, make sure the control you want to copy the resource from is selected in the Design surface. Then, go to the document outline and you will see the control selected in there. Right-click the control and select Edit Template/Edit a Copy.... This will create a copy of the style resource (defaulting to within you page XAML. but you have the option of other destinations.). You can then edit that private resource to your heart's content.
In terms of the amount of space around the TextBox, look for things like "MainBorder" in that style.
Update:
verdesrobert's method of getting a copy of the style is much quicker than mine :). Learn something new every day!

VB.NET Undo/Redo only the text in RichTextBox

I just want to know how to make the undo/redo system in VB.NET's RichTextBox perform only undo/redo operations only on text.. which means it will not include the text formatting.
I am making a code editor and i change the fonts based on the keywords given by the user. When I press undo, instead of undoing the text, it changed the font first, which is not what i want.
I tried using custom undo/redo system using stacks, but it has many bugs.
See this Example It's create Undo And Redo Function For TextBox But it's easy To Change To RichTextBox
Tell Me If it's fit for you.

Metro App Create Email Address Entry Xaml Control

How do I create a Control to input email addresses, similar to how capturing tags on stackoverflow works?
I am using C# and Xaml.
You will need:
TextBox(to show input area where you can type)
Popup(to show suggestions below TextBox like StackOveflow does)
ItemsControl(it goes into Popup, so you can just have collection of items and they will be displayed, note that ItemsPanel should be probably GridView)
Then you will need custom Button, that will be overlaid top of TextBox once tag has been added. You need to calculate how big is the button(width) and fill TextBox with empty spaces, to advance cursor further.
Also you need to control what keys are being pressed.
The effect you are after is probably that you recognize complete e-mail addresses, and render them in a custom way. I would do this by removing the completed addresses from the textbox, and wrap them in a skinned label (or maybe a custom control with a delete button).
The most straightforward way is to implement the textbox as a DockPanel with a border, suggesting that it is a text box. On the left side of your DockPanel, you have a StackPanel where you stack the completed address controls left-to-right. Then add a textbox with DockStyle=Fill to fill up the remainder of the DockPanel. Once you detect an email address is entered, you remove the characters from the textbox and add a matching control to the StackPanel.
There is probably a way to change the textbox contents without losing focus, otherwise you need to fix this though code.
Good luck!

Pass hidden data through XUL autocomplete textbox?

One of the controls needed in my xulrunner application is an autocompleting text box which allows the user to type a search term, then looks up completions in an array of objects (each having a generated UUID, canonical name, a list of search terms gleaned from related data, etc.) and allows the user to select just one. Currently I'm using a textbox element of type="autocomplete" and a Javascript custom search component, and it is successfully prefix searching all the search terms and providing completions below the text field, in the customary fashion.
The catch is that I'm not interested in the possibly non-unique label but the object from which the label came, and I can't see any way of passing the object or even any out-of-band UUID back into document land without modifying the XBL or rolling my own control from scratch. Essentially I'm seeking to do what could have been done in HTML with the option[value] attribute. I can't use the built-in type-to-search effect of a standalone menulist because I need to prefix search multiple fields of the object. Any recommendations? Thanks in advance.
I ended up rolling my own as a listbox inside a panel next to a textbox. Even composed into an XBL binding, this was less effort than I'd spent working with the built-in autocomplete textbox and trying to force it to handle what it wasn't intended to handle.