|
Subin Mavunkal wrote: but try to respect others
Well thats a bit rude, asking someone else to respect others when you abuse one of the most fundamental rules here. You made a mistake, and therefore you have been smacked.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Subin Mavunkal wrote: being a good programmer in life is nothing
Careful there, This is a programming forum.
Subin Mavunkal wrote: I know extra talenteddumb men who lost their mind on simple things
Fixed.
Subin Mavunkal wrote: Is this the way to give answer? or teach something.
Yeah, this will teach you to not cross post into inappropriate forum.
Subin Mavunkal wrote: I thought that there are programmers who are familiar with more than one language.
Yes, there are, and they'll visit each of their favorite languages forum, if they have time.
Subin Mavunkal wrote: And that forum to vc++ seems like it is totally inactive
Be patient.
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
modified on Friday, August 19, 2011 5:12 AM
|
|
|
|
|
Had you bothered to read the guidelines[^] before you started, and selected the forum appropriate to your problem (this[^] or this[^]), then you would have got a reasonable response. You have also been a member of CodeProject long enough to have learned this by yourself.
|
|
|
|
|
I think his turban is wrapped too tight. You're wasting your time.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
John Simmons / outlaw programmer wrote: You're wasting your time.
I know, but somehow I feel better for it.
|
|
|
|
|
The forum you want is this one[^] which has the same activity as the C# one. Your question had nothing to do with managed C++ or the CLI.
but try to respect others
Try to respect the rules of forums you post in.
|
|
|
|
|
Subin Mavunkal wrote: Bro.
I ain't your bro, and your attempt at placating me with non-existent familiarity offends me.
Follow the rules, or prepare to be harassed. It's as simple as that.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
modified on Friday, August 19, 2011 5:13 AM
|
|
|
|
|
I am looking for a framework or some site with a description of a possible direction of solution to speed up my development.
My functional design shows a number of screens with WPF listviews on them. All of the screen have a add/remove column button next to each listview. Now adding A column to a listview at runtime is easy. But with the amount of listviews and even more the amount of possible columns to add (400 or so) hacking in code behind will be the next nightmare, I am not even talking about changes. So I am looking for a clean generic approach.
Search the web but no results.
Anybody here been in the same situation? And can push me a bit in the right direction?
Oh MVVM ofcourse.
Thx. Any help is appreciated
|
|
|
|
|
Seems like you should be able to work something out in the VM layer based on a dictionary and implementing ICustomTypeDescriptor (or whatever the WPF version is called) on a binding class which is what the view model exposes a list of. Something like
class BindingWithCustomColumns<T> : ICustomTypeDescriptor {
T obj;
Dictionary<string, string> CustomValues { get; private set; }
public BindingWithCustomColumns(T t) { obj = t; CustomValues = new Dictionary<string,string>();}
public PropertyDescriptorCollection GetProperties() {
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(obj);
foreach(string key in CustomValues.Keys)
props.Add(new CustomPropertyDescriptor<T>(this, key));
}
class CustomPropertyDescriptor<T> : PropertyDescriptor {
BindingWithCustomColumns<T> host;
string key;
internal CustomPropertyDescriptor(BindingWithCustomColumns<T> host, string key){
this.host = host; this.key = key;
}
public object GetValue(object component) { return host.CustomValues[key]; }
public void SetValue(object component, object value) { host.CustomValues[key] = (string)value; }
public Type PropertyType { get { return typeof(string); } }
public Type ComponentType { get { return typeof(BindingWithCustomColumns<T>); } }
}
}
Then your view model needs to expose a IList<BindingWithCustomColumns<T>> as the property which you bind to the ListView. (That should probably be a BindingList or ObservableCollection if you want it to be linked with an underlying model list which will be of type T, not BindingWithCustomColumns<T>, so you can hook the collection-change events.)
|
|
|
|
|
Investigating this....
Thx.
|
|
|
|
|
I'm not really sure what Bob's response has to do with your question. Nothing at all from what I can tell . This is really a WPF question and not a C# question, but I read both boards and just dealt with this issue myself recently, so I'll help you out .
1) The WPF ListView doesn't support data binding on the GridViewColumnCollection out of the box. You can add support for this, not too difficult, but a little bit of work.
2) Once you have a WPF ListView that can support data binding on the GridViewColumnCollection, its just a matter of having your VM return a collection of columns.
3) Some gotcha's you'll run into:
a) a GridViewColumn can only be owned by one GridViewColumnCollection at a time, so you can't return a GridViewColumnCollection from your VM, you need to return an ObservableCollection<GridViewColumn>.
b) defining a GridViewColumn in code with bindings is a major PITA, so you should devise a way to load them out of a XAML file where you'll again run into "issue a" where you can't share GridViewColumn's.
All these issues are overcomeable... basically what I ended up with was a GridViewEx class that supported two-way binding on the column collection. Remember, you are going to need to save column widths and column order .
|
|
|
|
|
What it has to do with the question is that you can bind a ObservableCollection<BindingWithCustomColumns<T>> as the ItemsCollection of a ListView and it should act like an ObservableCollection<T> except that you can also add extra columns. Though thinking about it some more you probably want to make the dictionary static if you want the same extra columns for every instance of T ... not sure what the data binding does if the list of things it's binding to claims to have different properties.
(Note that my solution is done by analogy with something similar I did to bind a WinForms DataGridView with dynamic column binding. I wasn't aware that you could explicitly bind the columns as your post seems to indicate.)
|
|
|
|
|
Ah, your solution is for a WinForms DataGridView . A WPF ListView is a *completely* different animal. ListView.ItemsSource would point to an ObservableCollection<SomeClass>, but columns are defined in a *completely* different place. Also, when you define the columns, you need to define what member of SomeClass will be shown for each column. The WPF ListView column collection doesn't support binding out of the box as I indicated in my other post. You have to do some work to get that to work. In WPF you generally need to tell the control what property to display. Another note is that WPF XAML does NOT play nice with generics. You should generally avoid using them for objects that are going to be displayed. Well, I don't mean don't use them, but I mean, you need to do something like:
public SomeClassCollection : ObservableCollection<SomeClass>
{
}
and then use SomeClassCollection everywhere since you can't specify ObservableCollection<SomeClass> in XAML.
|
|
|
|
|
Oh right you have that whole ItemTemplate business. I remember now.
So yeah treat my post as an interesting diversion and do what this guy says :p
|
|
|
|
|
Trust me... once you pick up MVVM & WPF, you'll wonder why you ever wasted your youth on MFC and WinForms .
|
|
|
|
|
I dodged MFC (thankfully) but I actually quite like the WinForms approach. I don't really see the point in WPF – it's a great way of producing slightly confusing applications that violate the normal conventions of desktop apps, and its layout engine is brilliant at producing something which is nearly but not quite what you want. Silverlight makes more sense, as that approach to UI is more in line with the way the web works.
I do like the MVVM pattern, it seems to be one of the cleanest 'MV*' approaches for separation of concerns – but there's no reason one shouldn't write WinForms or even web code in a similar style (and in fact ASP 4.0 seems to have gone down that road with its MVC).
|
|
|
|
|
Huh? How can you like Silverlight, but not like WPF? They are the same thing! Silverlight is a stripped down version of WPF. Winforms is pretty much MFC with primitive data binding support. Not quite sure what you find confusing about WPF. The layout engine always gives me exactly what I want as its a million times more powerful and flexible then the Winforms one. Oh well... too each his own I guess.
|
|
|
|
|
I like Silverlight and not WPF because the types of UI you produce fit quite nicely into the Web 2.0 paradigm, but generally not into what is expected from a desktop app. It's quite difficult in WPF to produce something that looks like a standard Windows app (right?). I'm sure there's some unfamiliarity as well but it just seems more suited to the web to me.
|
|
|
|
|
? Out of the box, WPF will produce apps that look exactly like Winforms apps. Its just, remember all that crazy code you wrote to do Owner Draw & Custom Draw controls? SetPixel, GetPixel, BitBlt, etc? In WPF that 1000 lines of code is now 2 lines of XAML pretty much. WPF is pretty much Winforms + superior data binding + superior custom drawing support.
|
|
|
|
|
Modifying controls in WPF requires you to replace the XAML template, doesn't it?
Maybe it's just that all the material on WPF focuses on the 'cool stuff' and not making normal apps. Even Microsoft's introductory topic[^] is 'shiny' and web-like in the interfaces it shows, though.
|
|
|
|
|
I had the feeling that BobJanova's answer was not very related, hence the 'investigating....'
I didn't even notice we have a special WPF section. Guess I have been posting in the wrong section.
Thanks again for all the input!
|
|
|
|
|
Hi Team,
Is it possible to remove WATERMARKS from existing PDF.? using C#.?
thanks
Satish
|
|
|
|
|
Yes, but only by accessing the raw data of the file and re-writing it to a new one. However, something tells me this may not be legal so I will not suggest a solution.
|
|
|
|