c# - Programmatically adding/removing a Grid in WPF? -


i new wpf having worked winforms on occasion , still trying head around wpf mentality, given background embedded coding, seems quite removed.

in project need create grid panel "template", i'll call "fred" (where in case fred cluster of graphically customized buttons) , spawn multiple instances of ui programmatically based on external events. finding hard see obvious way (perhaps because there maybe multiple ways?) , have looked controltemplates, styles , custom elements. suspect solution lies in latter concerned might thinking in wrong way. me seems make sense visualize fred grid resource can programmatically invoke somehow when need create new instance, given found hard "google" thing perhaps going wrong?

i apologies if bit vague.

my question here 2 fold:

  1. is sensible way achieve end goal i.e. if need programmatically spawn cluster of customized buttons (fred) make sense contain these in grid can accessed main c# or there more standard way missing achieve this?

  2. depending on answer (1) there code examples achieve this?

the concept looking "itemscontrol" (which usable class, , has several derived classes listview , listbox) in combination datatemplates.

in case make "fred" datatemplate (commonly direct descendant of itemcontrols itemtemplate property in xaml). bind itemssource collection (should observablecollection<t> runtime additions/deletions).

all of relies on using mvvm pattern (which coming winforms aren't). suggest looking @ msdn, stack overflow, excellent blog series reed copsey: http://reedcopsey.com/series/windows-forms-to-mvvm/ or google "wpf , mvvm" learn more.

to answer questions explicitly:

  1. yes; have right concept thinking in winforms terms/practices. use mvvm instead.
  2. yes; there many resources available.

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -