Editable sequence in WPF - wpf

I need a control that allows a sequence of controls to be edited. Each control has a single associated value and the value of an editable sequence would be the sequence of those values. Editing the sequence refers to adding new elements, deleting existing elements and reordering elements.
I've written an editable sequence control that displays a dock panel with a list box, up and down arrows and a text box. Entering text into the text box and pressing return adds a new element with that name. Pressing the up or down arrows moves the currently selected element. Pressing DELETE when an element is selected removes it.
I'd like to examine other options. Do any built-in WPF controls provide this functionality? How might I compose existing controls to create what I need? Are there commercial solutions that would make my life easier?
EDIT: For example, it would be more user friendly to allow elements to be reordered using drag-and-drop. What is the easiest way to accomplish this?

Related

Changing the data in a specific area of a window, Caliburn.Micro, WPF

Here is my need. I think a user control is what I need but I am not sure if its the best or even how to use it.
What I have. My main window has a menu with a "help" menu. When you click help, a new window opens, I have a column, At the top of the left column has a drop down box of "Major Titles", a ListBox below that that populates based on the combo box selection. This will be about 25% of the window width. All this works.
When I select an item in the list box a page,contentControl or user control is displayed to the right with verticle scroll bars so the window does not need to resize, the information I display that changes based on the list box selection will have only visuals like text block, label, images. There will be no user interaction with the changeable pages Just formatted Data.
What would be the best way to approach this? Can anyone offer an easy example?
I was thinking of using a user control and change the user control based on the selected list box item.
Ok, I got this figured. After reading a lot of posts and blogs. Seems people sometimes want to make things more complicated then they actually are.
What I wanted, a permanent list box on the left 1/6 of the window. The list box contained string names for "help subjects". On the right 5/6 of the screen I added a groupbox with header and in group box I added a usercontrol. The content of the control is bound to a property called 'ActiveView'. The list box selected value property is bound to 'SelectedListItem' property.
When you change it set 'SelectedListItem' a method is called 'SetActiveControl'. SetActiveControl has a switch/case that sets like in the example:
``Case "Setup":
ActiveView = new SomeSelectionViewModel();
Break;
I have created a user control in a folder inside the Views folder called HelpControls, I also created the same folder in ViewModels. I have classes matching the user controls and everything is bound together.
Ultimately when you click the list box item, the associated ViewModel is called and in turn populates the user control on the window with the appropriate data.
I need to later look into, using one ViewModel for all the controls, I know that can be done using Cal:Model.View = ViewModel name. In the xaml of the control. I'm just not sure how to call the appropriate user control view when an item is selected. Either way this would become a view first design and I thought I read, Caliburn. Micro was intended as a ViewModel first design.

How to put ellipsis (...) in RichTextBox

I want to put an ellipsis (..) in the rich text box.
In normal TextBlock, TextTrimming="WordEllipsis" has a property that limits the length to allow ellipsis representation, but rich text boxes do not. And it should only be implemented as a rich textbox now. Text blocks are not allowed.
I'd like to trim by two or three lines and add an ellipsis (..) option. Is there any good way?
I want to show you how I'm using RichTextBox, but the reputation is low.
You don't
The ellipsis concept is, as stated by grek40, something that only works when displaying text.
As an example, say the ellipsis is displayed, and the user tries to partially select some text in your RichTextBox, including the ellipsis, what would the selected result be? You can't tell.
Maybe
Since an ellipsis is usually a replacement for a Scrollbar, hiding text instead of allowing you to access it by scrolling, you might be able to fake it by using a WPF Style.
Create a Style that displays an icon/picture of an ellipsis (placement is up to you) whenever the Scrollbar visibility trigger is triggered. You would need to disable the Scrollbar once the ellipsis is visible.
This obviously requires more effort than simply setting a property, and it can easily become a User Experience nightmare if not carefully implemented, so be warned.
Note: Another comment (by Walt Ritscher) linked to a similar question, the solution there is similar to this one.
Alternative Maybe
Another faked ellipsis could be achieved by using two different RichTextBox controls.
The first RichTextBox would have set ReadOnly to true. Trim your text to a maximum allowed length, and append an ellipsis and display it inside this first RichTextBox.
When the user need to edit the text hide the first RichTextBox and display a second RichTextBox that contains your entire text.

WPF - need multicolored combobox

I'm trying to create a wpf combobox where certain keywords in the item text are always a different color (eg, phrase "abc" should always be blue, even if it's just a part of a longer word). Ideally, this should apply to all templates of the combobox: selected item, dropdown items, and the editing textbox as the user is typing new entries ("IsEditable" is set to true).
My initial thought is to use rich text controls for the templates of the combobox, but I'm having difficulty figuring out how to set the editing template. Even then, I'm not sure how to proceed on enforcing keyword coloring as the user types. Suggestions?

Add CheckBox as Bullet inside RichTextBox

I was wondering if it was possible to create a list that has check boxes in place of bullets.
I want to create a lengthy list of questions inside RichTextBox and would like it to automatically place a small check box prior to each question. Much like it would place a bullet after each time I press 'enter'. I don't see a check box as an option in the list of bullets.
WPF RichTextBox doesn't support checkbox as bullet. For your requirement you need to add check box as InlineUIContainer in RichTextBox.Here is sample to play with flowdocument

How to change Grid Content?

I am asking for a programming approach.
This is my problem:
I have a WPF window, with a ComboBox at the top.
When user select the item in combobox, depends on the selection, the Grid below it will show a corresponding element, for example: if use choose Display from combobox, then the element in Grid will change to a ListView; and when user choose Add from combobox, the element in Grid will change to a form(textboxes).
Should I create several Grid, collapse them, and show them only when user make selection? Or any other more brilliant ideas?
Thanks.
Put a UserControl in the cell, and set its Content according to the control selected in the ComboBox.
There can be two ways:
You add one panel containing the controls required for each of the items in the combobox. You can hide all of them and on SelectedIndexChanged, you can show the appropriate panel. This will need more memory, but the implementation is simpler.
The other way will be to have a single panel and render the controls in run time on SelectedIndexChanged. This will need less memory, but will be complex to implement. Also rendering on run time might need some additional time (so the throughput).
What you can do is place a Panel(Like Grid, DockPanel) below the combobox and based on it's selection, dynamically add/remove controls in the panel.
For ex: If the user selects Display, then, remove all the child elements of the Panel and add a GridView.If Add is selected, remove all child elements and add a TextBox.
After adding, attach an event handler in code behind to perform the action you would want to perform.

Resources