WPF textblock which allows the selection of text - c#

I have a TextBlock in my app that has text with some URLs in it. At the same time, I want the text to be selectable and copyable. If I use the TextBox element I loose the ability to add Hyperlinks and if I use the TextBlock I loose the selection functionality.
Having all that said, what do you suggest to keep both the hyperlinks and the select (with mouse and keyboard) ability?
Edit: this application is a chat app, and I want the incoming message to be selectable while the URL are clickable.

Not sure but perhaps you can use RichTextBox. See: Adding hyperlink in textbox.
You will have to manage to find links when the user type one and modify the text in accordance (inserting an hyperlink) with the user text. Or add a way, like a ContextualMenu, to offer the user to add an hyperlink.
I'm not sure you can find a control that do exactly what you want. Good luck!

The Webbrowser control will allow text selection and hyperlinks.

You can do something like this:
<Label>
<Hyperlink NavigateUri="bob#contoso.com">
<Run Text="bob#contoso.com"/>
</Hyperlink>
</Label>
You can style appropriately and add commands to Hyperlink if you want to actually navigate to that link when clicked

Related

Display both options of ToggleButton in WPF as links with custom styles

I am trying to display two links namely "Entire Content" and "Summary" on a page. I wish to use a ToggleButton so that the relevant information can be displayed by switching between the two options.
However, I wish to display the toggle button options such that both the links are visible at all times and the one which is selected should be highlighted (probably styled with a bold, italic or underline), just to let the user know the currently displayed content.
What would be a good way to achieve this?
How about using two grouped radio buttons styled to look like toggle buttons.

Configure the selected control's Text of the user Control

I am creating a group of panels with labels in it. Depending on the requirement of the User. Kind of mimicking the Tab control here. Where like the Tab control's Title is editable, i would let the user to configure the name of the labels at design time. How possibly can i achieve it?
In the event Handler of the Label, change the label to a TextBox. When the TextBox looses focus, replace it with a Label again
Please chehk the following thread (Header Editable Tab Control in WPF).
If you use WPF, then this is exactly what you need for your work. If you use another template, maybe still can add some tips. :)
Good luck

Windows Phone Search box Tags on tapping search results

Is there any library available for Windows Phone with the tags in a search box feature? So if I start typing age, the search box should predict agent and agent smith etc and on tapping the predicted results, the search box gets filled with the tags (example image attached). Handling events like, backkeypress highlights the tag and another backkeypress removes the tag etc. Predicting results is easy, what I am looking for is all the events handling for search box with tags. Any free/paid library for the same?
There are a few AutoCompleteBoxes (Telerik, Windows Phone Toolkit), but the just work for one item. If you want more items, you need to create the control by yourself.
A lot of third party controls are available but you should prefer to write your own control. I used http://wpfactb.codeplex.com/releases/view/42340 control but you have to customized it and bugs are there to be fixed .
So I will suggest you to get hint from this and write your own control.
For something as specialized as this, I would write it myself. And XAML suits really well for such tasks.
One horizontal stackpanel with custom styled buttons being added, and one LongListSelector for the results.
This is very simple to implement.
Set the InputScope in your textbox.
On typing , you will get the possible result.
When you tap on the respective suggestion, you will get the value.
Create a Grid or Stackpanel and create a ellipse which should hold the tag value.
On tap of the value, add the value inside the created ellipse.

What WPF control should i use for my window?

So im making a WPF project where one of my windows has to let the user see a text. Select parts of this text for being put into an array of strings and no more than that. So he/she musnt be able to edit anything in the text only highlight parts and then click on a button. What WPF control would be smart to use for this?
I'd probably just use TextBox with IsReadOnly set. The various selection properties are all you need after that.

Selectable TextBlock or a TextBox with formatted text in WPF

I have a situation where I need to show a formatted text (normal, bold, highlighted) and should also be selectable so that user can copy the text.
I have used textblock where i can apply multiple formattings using Inline content flow elements but unfortunately it's text is not selectable.
Whereas Textbox allows to select text and copy to clipboard, it does not allow me to format text.
Is there anything I am missing or I'll have to build a custom control?
I'm not sure how much style you're wanting to apply, but I find the following site to be useful to determine the best way to use Silverlight controls:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/
This specific URL has some information on how to style a Textbox:
http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=TextBoxSnippet
You can use RichTextBox. It control is selectable and support formatted tex.

Categories

Resources