Tag editing in a WPF TextBox - wpf

I want to implement a custom TextBox that will allow me to edit tags. Hotmail's "To" TextBox is the best example I can think of:
Also Facebook's "To" implements the same concept:
Oh yeah, and StackOverflow does it too to tag a question :)
Does anyone have some experience in building something like that in WPF? What would be the first steps that I should make?

I believe this Tokenizing control does most of what you're looking for:
http://blog.pixelingene.com/2010/10/tokenizing-control-convert-text-to-tokens/

I'd try the following:
implement a TagEditor, which has the functionality to edit a single Tag (based on an AutoComplete TextBox that is swapped with a TextBlock once an existing Tag has been recognized or editing is ended)
create an DataTemplate that uses the TagEditor
create an ItemsControl that utilizes the DataTemplate
that breaks it down to three challenges, of which only the first is a bit tricky, but solveable with the given keywords and stackoverflow ;-)

Related

XAMDataGrid column template

i have to show Text and Graphical status in one(same) column of the XAMDataGrid.
can please someone suggest me template for this.
There are two ways you can accomplish this. The first is to use a Style targeting the CellValuePresenter where you change the Template. If you are not editing the values, this is the recommended approach and there is an example in the Embedding a Custom Control in a Field help topic.
The second way to do this is to create a custom ValueEditor which is better if you need to allow editing. You may be able to use the ControlHostEditor that Andrew Smith provides in the sample in his Hosting WPF Controls in a XamDataGrid Cell blog post.

How to use a control equivalent to the WinForms DataGridView in WPF

I've been creating an inspection form using WPF and I need a place where users can type an unknown amount of comments (hence why I'm not using textboxes). In my WinForms version of this application, I used a DataGridView and I could enter in as much information as I wanted to. I'm looking to do the same with a DataGrid or an equivalent control in WPF.
WinForms Example
I need to be able to do the same thing in WPF but I can't seem to add any rows in the DataGrid. On top of that, when I try to check CanUserAddRows it unchecks it immediatly.
So I checked out Vincent Sigal's blog post about this issue. He mentions something interesting:
... but beware of CanUserAddRows and CanUserDeleteRows as they can appear a little magical. Their values are coerced based on other properties such as DataGrid.IsReadOnly, DataGrid.IsEnabled, IEditableCollectionView.CanAddNew, and IEditableCollectionView.CanRemove. So this is another thing to watch out for when editing. If you run into a situation where you set CanUserAddRows or CanUserDeleteRows to true but it is changed to false automatically, check that the conditions below are met.
I verified this and my DataGrid is not read-only and it is enabled. Although, I have no idea where to find the IEditableCollectionView.CanAddNew and IEditableCollectionView.CanRemove ...
I don't think my situation should require a binding event on the DataGrid since the user is supposed to enter his comments directly into the DataGrid ... Is what I'm trying to do even possible? Perhaps I should use a different control?
I have to admit that I stopped reading through your question after the first paragraph, so please forgive me if I have understood you wrong... but if you just want to enter multi line text into a TextBox in WPF, you can do it by setting a couple of properties on it:
<TextBox TextWrapping="Wrap" AcceptsReturn="True" />
For a DataGrid, you can set these properties in the DataGridTextColumn.ElementStyle and/or DataGridTextColumn.EditingElementStyle as the WPF DataGridTextColumn multi-line input post shows quite nicely.
Please let me know if I did misunderstand you.
UPDATE >>>
Ok, so I came back to read the rest of your question... answering without reading the question can be risky business on this site. It's just as well that I did too, as I see you also want to know how to use the DataGrid.
I have to start by saying... take a deep breath... WPF is very different to WinForms... very different. In WPF we manipulate data rather than UI objects, so to add a new row actually means adding a new item to a collection. You can find a complete working example on the DataGrid Class page on MSDN.
Please also view the WPF DataGrid Control page on WPF Tutorial.NET for more examples. WPF has a lot to take in for new comers and can be quite bewildering, but it's well worth the trouble when you get into it.

WPF Customise NavigationUI Control

Good Afternoon,
I am trying to customise the NavigationPanel UI Back and forward button, i basically just want to change the colors. I cannot find a property that can be set so i am a little stuck.
I believe the way forward is to amend an existing template and set the Page.Template property as the new control template? Am i going down the correct route? Where does this Xaml belong to, under the Application.Resources / Page.Resources?
I believe the Template is http://msdn.microsoft.com/en-us/library/aa970054.aspx
Apologies if this is a basic question but i am trying to learn Xaml / Wpf.
Thanks for your help in advance...
I found a good example of this under samples on Msdn:
The link:
http://code.msdn.microsoft.com/Customized-NavigationWindow-ced9d7af
I then used the default template as above and amended the xaml to the effect i wanted. Simple when you can find a sample. :-)

Is WPF's FlowDocument content user-editable?

I understand and have read about using WPF's FlowDocument to create an XML style document on screen, but is the content presented editable by the user, or is it read only? And, if so, how is this done?
My question mostly centres around the use of the listitem control because it would be nice to be able to edit the order of the list items presented for use in my program, rather than me having to create my own custom control(s).
Regards.
FlowDocuments as objects are editable, if they can be edited in the UI depends on the controls that use them. If you use them in a Page they are not, if you use them in a RichTextBox they are.

Customize DataGrid Group Name

I'm using the Silverlight Toolkit DataGrid. Grouping is working fine, thanks to the PagedCollectionView class.
My question is, is there an easy way to customize the text of the group header? When I group by "CurrentBook.SubTitle" (just testing it out - grouping by a book's subtitle doesn't actually make sense) it displays "CurrentBook.SubTitle" in the group header of the grid, when I'd prefer just SubTitle.
Obviously I could just make a new property in my ViewModel called SubTitle that passes along CurrentBook.SubTitle, but I'm just wondering if there is any built-in way to affect the group header text.
Its a little difficult to answer this without seeing an example of your code. Follow the advice here and make a style for the DataGridRowGroupHeader with something like PropertyName="{Binding Collection Path=Name}" and add that style to the RowGroupHeaderStyles Property. Im not sure how much more specific I can get without seeing more though.

Resources