What is the easiest way to change a ComboBox, in WPF, so that the Popup has an additional row that could be used to perform a function. For example,
--------------------------
| [Button Add New Item] |
| Item 1 |
| Item 2 |
| Item 3 |
--------------------------
I know that the ComboBox has the "PART_Popup" that might be able to reuse. But it feels like rewriting the entire style or combo box control is overkill.
Any help would be greatly appreciated. Thanks!
You'll need to edit the controltemplate, and since you've found PART_Popup, you know where to look. Drop a button inside the DropDownScrollViewer above the ItemsPresenter. You might have to play with the template a bit to make it exactly how you want it to look, but you're on the right track.
Related
I'm struggling at making a datagrid that looks like this :
|Column 1 | Column 2|
| data1 | data2 |
|Column 3 | data3 |
I've no problem doing this using a simple grid and defining rows + columns but I can't do it using a datagrid because <DataGrid.Rows> is not available. The only few posts I found about it suggested to make a grid but if it's possible to do that using a DataGrid, I would appreciate it.
The DataGrid maps a column to a property of the underlying type T in its IEnumerable<T> ItemsSource, and generates a row per instance of T. This is how it works basically.
If you want to be able to add columns or/and rows in some other way, you should use a different approach. The built-in DataGrid control won't work as expected anyway.
In WinForms, is there a way to add a non-breaking hyphen to a System.Windows.Forms.Label control?
e.g. Don't break like this:
======================
| VB is SO un- |
| cooperative! |
======================
Instead break like this!
======================
| VB is SO |
| un-cooperative! |
======================
If you want to use the Forms Designer you could select the Label's Text property. Click on the dropdown arrow on the far right and type your text. You could break it at the desidered position by pressing SHIFT+ENTER.
In code it is simply
label1.Text = "VB is SO\nun-cooperative!";
or in VB.NET
label1.Text = "VB is SO" & Environemnt.NewLine & "un-cooperative!"
Check this, its working properly
text does not break after or before '-'. i have tested in my testing project and its working properly. even i reduce the width of label it get cut from the right side as displayed in my screenshot.
still getting problem then you have another option is that create custom user control for label and write some code for word wrap there are lot of code exist on internet for wordwrap process. available in VB.net also. btw windows form does not allow any event or override method that you can handle it for wrap text.
I have a window control that contains four user controls (screens) in a wizard style environment. (i.e. only one user control will be viewable at all times) The window control has a series of buttons that act as the primary navigation between all the user controls.
----------------------------------
| |
| SCREEN x of 4 |
| |
----------------------------------
| |
| Back Next Cancel |
----------------------------------
The wizard will build a profile of information as the user completes each screen. I have defined a Profile type that implements INotifyPropertyChanged that will contain the information the user provides. So far, so good.
My question is: When the first user control (Screen 1 of 4) modifies the Profile type, how do I alert the Window? I'm trying to use MVVM and not use code-behind.
I tried setting up an event on the first user control. The window would be the subscriber to that event, but that's not working.
Is there a better approach for a user control to alert the main window that something has happened?
MVVM uses Commands instead of Click handlers. So you should have an implementation of ICommand interface ready to use or you can get it from any MVVM oriented Framework
If you want to keep things simple, here is the link how to use commands
What MVVM framework are you using? Most of them have an implementation of the Mediator pattern to handle communication between view models.
I use Cinch V2 and here you can find an explanation of how it implements the pattern and also see some code showing how to use it.
If you are not using a specific MVVM framework take the ideas from the implementation above and apply to you code!
I am using the LongListSelector from the Silverlight for Windows Phone Toolkit.
For each group I would like to show a small group related icon, in the group header.
Group A
Item 1
Item 2
Item 3
Each of the items have the same key, and are grouping correctly. And each item has the same image. But when I change my GroupHeaderTemplate from the key to something else. It doesn't seem to handle this correctly.
Typically you see examples that use a "Group" object which is based on the IGrouping<TKey, T> style object which implements IEnumberable and has a single Key property.
However there is no reason why your group object can't also have a whole range of other properties like "Name" and "ImageSource" whatever that you will be able to bind in the group item templates.
Take a look # these two articles for insights on LongListSelector
WP7 LongListSelector in depth | Part1: Visual structure and API
WP7 LongListSelector in depth | Part2: Data binding scenarios
Can you show us some more information with regards to your source data and the XAMl that you're using. It sounds like you need to expose a path to the image you want for each group and then bind the Image element in the GroupHeaderTemplate to that property.
I am new to WPF and am wondering how to best achieve a master detail grid as shown below.
The user will be able to press the right/left arrow keys to open/close Parents or click on the icon to achieve the same result. The data structure will be a parent/child 1 level deep.
How would I go about this?
-------------------------------------
Parent1 (P1) ^
-------------------------------------
P1 - Child 1
-------------------------------------
P1 - Child 2
-------------------------------------
Parent2 (P2) ^
-------------------------------------
P2 - Child 2
-------------------------------------
Parent3 (P3) >
-------------------------------------
Thanks in advance...
A couple of possibilities:
Use a TreeView, with suitable HierarchicalDataTemplates for the parent and child levels. I believe this will handle the arrow keys for you, but you may have to do more extensive templating to align everything correctly (ItemContainerStyle and the TreeViewItem.Template property would be the starting point).
Use an ItemsControl, and have your ItemTemplate include an Expander. The Header of the Expander would show the parent. The content of the Expander would be another ItemsControl, bound to the child items and with its ItemTemplate set to the appropriate detail view. Again, you would probably need to template the Expander to put the "expand/collapse" icon on the right rather than its default position on the left. You'll need to handle the arrow keys yourself in this case I think. The advantage is that this will naturally give you "stack" alignment (accordion style) rather than indenting.