one button with wrapped list view
my searched result are:
1.worst approach: put add button on the wrapped list view.
2.bad approach: set two data template for list view.
3.?
thanks
I've had something similar a while back. In the end I decided to add a fake data item where I needed the button.
Say I had a list of MyDataItem, I created a derived class MyFakeDataItem and added that at the end of the list, after I finished populating it. In the WPF I created two data templates, one for each class, and a selected to decide.
I think it turned out quite elegant, since it allowed me to easily override any real functionality I had on MyDataItem, and add a command on the fake one to suit my needs.
Hope that helps.
Related
I have an (outer-)dataview (with tpl, store etc) which works fine. I can reorder the items (drag & drop) and edit the data.
Now I need to extend the functionality. Some items in the outer-dataview needs to show additional data in an inner-dataview. Items within this inner-dataview also must be reordered and edited. It is even getting more complex: also these items could have additional data to be shown insite the items etc etc.
By nesting the dataviews insite other dataview-items the user has a good presentation of the grouped data and can easily reorder the data by drag & drop.
I’m struggling what the best way is to build the nested dataviews. The best thing I came up with was to loop all nodes in the outer-dataview and create new inner-dataviews and use the renderTo-functionality of the dataview directly into the outer-dataview-items.
This works fine but each time I change data in the one of the outer-dataview items the related inner-dataviews disappear, because the dataview updates the dataview item.
It would help if I could re-insert the inner-dataview(s) again.
Does any one have a good suggestion how to realise the nested dataviews?
Arno
Issue Solved and the solution was quite simple.
After the creation of each dataview I dynamically render the inner-dataview into the items. simple...
How could I assign a custom class (Customer, Order, etc) to a DevExpress PropertyGridControl (or native Windows.Forms.PropertyGrid) at Design Time?
The PropertyGridControl.SelectedObject's dropdown list shows only the other Controls used in the form, but not custom fields declared by me. For instance:
Dim oCustomer As new Customer
I'd like to customize MultiEditorRows, styles, etc at design time to show my object properly.
At runtime it's as easy as:
myPropertyGridControl.SelectedObject = New Customer
Any help would be greatly appreciated. Please excuse my bad english.
At design-time only components that exist on a form can be selected as the grid's SelectedObject. Of cause, you can make your object a Component descendant and drop it onto a form to select it. But, I don't think that you really need this. As far as I understand, you need to generate grid rows at design time to customize them. If so, it's better to use the Rows Page designer to manually add the required rows and customize them.
I wrote my own sub-class, for some selection stuff and paging etc. But those all worked with the renderer(), which required them to return a string.
This worked fine, I created some image-tags and returned those.
But how does this class work in detail?
I want a sub-class which displays a chart in a cell, which should technically be no problem, but the renderer() doesn't seem the right place for it, since it only works for strings.
Does the Class get instantiated for every row? or is it really just one instance for a column, which methods get called for every row with the needed data and the instances don't hold any state about the rows?
The renderer() mechanism is actually implemented in Ext.grid.column.Column, for which there is one per column.
As you have mentioned, the renderer() function returns a string, which could be an HTML string (which could be rather complex - have a look at the templates used by ExtJs for the standard columns). But you cannot return a component (chart).
To the best of my knowledge (based on my own understanding and replies to similar questions), ExtJs does not offer a straight-forward way to render components within grid cells. If you really think about it - you are asking a grid for much more than its intended role. It was designed to present records per raw, with the addition of simple user interaction facilities, like checkboxes.
But what you are really asking for is more of a way to layout charts, for which problem i suggest you look into the Table layout.
Alternatively you should be able to render a chart into a dom element, which will be defined in your own custom column template. But I will consider this to be an involved task.
I'm writing a WPF application while mostly adhering to the MVVM design pattern. The application has various educational modules broken up into different categories to be accomplished by the user. The modules are organized into a hierarchical menu. My ViewModel has a class called MenuPageViewModel which exposes the information needed to render a MenuNode. Naturally, the terminal elements in the menu tree have content that I'd like to display to the user. This content can be one of many different types of modules. Currently, when the user selects a module in the menu, I can't see any way around using a large conditional block to determine what type of ViewModel I'd like to return to be displayed based on the type of the MenuItem's Content Property. For example...
if (CurrentlySelectedMenuItem.Content is Lesson)
return new LessonViewModel(CurrentlySelectedMenuItem.Content as Lesson);
if (CurrentlySelectedMenuItem.Content is SkillsCheck)
return new SkillsCheckViewModel(CurrentlySelectedMenuItem.Content as SkillsCheck);
Can someone give me a hint to a more elegant and maintainable approach? Right now, if I add a new module type, I have to remember to update this conditional block, and that just sort of annoys me.
Thanks.
If you are using Unity/Prism then using the container to resolve the object would be my first preference.
_container.Resolve(Type.GetType(strObjectType)) as BaseViewModel;
where strObjectType is a string with the type of class you want to create (eg "LessionViewModel" )
if you are not using Unity, then reflection works
Activator.CreateInstance(strObjectType) as BaseViewModel;
with both solutions you need to have the string with the class type on your menuItem.
A third option is to have a factory, but it would probably end up having a conditional situation within it or will contain the code i just listed.
Basically I use lists to display information, these lists contain custom data items I have created, they all look similar and have some of the same controls in them, essentially they need to look the same colour, font etc. At the moment, I just seem to be repeating code over and over each time a change is needed i.e. colour.
I have been wondering if it would be a good idea to create a generic data item which all the lists use and then just collapse controls which aren't needed.
So I was going to create a user control called something like "GenericDataItem". This data item will contain all the controls that each data item would need, then use dependency properties to collapse controls not required.
My question is would this be the right way to go about this, or is there a better way?
Thanks.
Not sure I got the point, but using DataTemplateSelector could help you.