Click here to Skip to main content
15,910,773 members
Home / Discussions / C#
   

C#

 
GeneralRe: Inheriting a template class Pin
Richard MacCutchan18-Aug-11 2:10
mveRichard MacCutchan18-Aug-11 2:10 
GeneralRe: Inheriting a template class Pin
#realJSOP18-Aug-11 8:17
professional#realJSOP18-Aug-11 8:17 
GeneralRe: Inheriting a template class Pin
Richard MacCutchan18-Aug-11 9:25
mveRichard MacCutchan18-Aug-11 9:25 
GeneralRe: Inheriting a template class Pin
BobJanova18-Aug-11 1:32
BobJanova18-Aug-11 1:32 
GeneralRe: Inheriting a template class Pin
#realJSOP18-Aug-11 8:16
professional#realJSOP18-Aug-11 8:16 
GeneralRe: Inheriting a template class [modified] Pin
Subin Mavunkal18-Aug-11 19:49
Subin Mavunkal18-Aug-11 19:49 
QuestionGeneric framework or pattern for adding colomns to a WPF ListView Pin
Vincent Beek17-Aug-11 0:28
Vincent Beek17-Aug-11 0:28 
AnswerRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova17-Aug-11 4:54
BobJanova17-Aug-11 4:54 
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>();}
 
 // bunch of methods that need implementing to do nothing

 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;
  }

  // some more stuff you need to implement

  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.)
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
Vincent Beek17-Aug-11 7:19
Vincent Beek17-Aug-11 7:19 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
SledgeHammer0117-Aug-11 8:02
SledgeHammer0117-Aug-11 8:02 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova17-Aug-11 9:04
BobJanova17-Aug-11 9:04 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
SledgeHammer0117-Aug-11 9:36
SledgeHammer0117-Aug-11 9:36 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova17-Aug-11 9:44
BobJanova17-Aug-11 9:44 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
SledgeHammer0117-Aug-11 9:48
SledgeHammer0117-Aug-11 9:48 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova18-Aug-11 1:24
BobJanova18-Aug-11 1:24 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
SledgeHammer0118-Aug-11 5:04
SledgeHammer0118-Aug-11 5:04 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova18-Aug-11 5:35
BobJanova18-Aug-11 5:35 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
SledgeHammer0118-Aug-11 5:43
SledgeHammer0118-Aug-11 5:43 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
BobJanova18-Aug-11 6:16
BobJanova18-Aug-11 6:16 
GeneralRe: Generic framework or pattern for adding colomns to a WPF ListView Pin
Vincent Beek17-Aug-11 20:19
Vincent Beek17-Aug-11 20:19 
QuestionRemove Water Mark frm existing PDF Pin
satish chary garu 16-Aug-11 23:45
satish chary garu 16-Aug-11 23:45 
AnswerRe: Remove Water Mark frm existing PDF Pin
Richard MacCutchan17-Aug-11 0:03
mveRichard MacCutchan17-Aug-11 0:03 
AnswerRe: Remove Water Mark frm existing PDF Pin
Hari Om Prakash Sharma17-Aug-11 0:04
Hari Om Prakash Sharma17-Aug-11 0:04 
GeneralRe: Remove Water Mark frm existing PDF Pin
satish chary garu 17-Aug-11 0:08
satish chary garu 17-Aug-11 0:08 
GeneralRe: Remove Water Mark frm existing PDF Pin
Dave Kreskowiak17-Aug-11 1:51
mveDave Kreskowiak17-Aug-11 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.