xaml - WPF Binding a Dynamically Added Control -


i adding "company" ribbonapplicationmenuitem in ribbonwindow following code:

  var reset = datacontext icompanies;   if (reset != null)   {      // todo: create interface populate mymenutems     var mymenuitems = new list<string>();     foreach (var item in mymenuitems)     {       var newbutton = new button { margin = new thickness(2), content = item };       menuitem_company.items.add(newbutton);     }   } 

my xaml looks this:

<ribbon:ribbonapplicationmenu tooltiptitle="application menu">     <ribbon:ribbonapplicationmenuitem          header="company"         x:name="menuitem_company"         imagesource="images\largeicon.png">                          </ribbon:ribbonapplicationmenuitem> </ribbon:ribbonapplicationmenu> 

how bind new button in code when add menuitem_company? need bind property in datacontext.

thanks, eroc

var newbutton = new button { margin = new thickness(2), content = item }; binding b = new binding(); b.source = reset; b.path = new propertypath("somepropertyondatacontext"); newbutton.setbinding(button.isenabledproperty, b); 

varying assumptions in code...but should give idea start...


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -