c# - WPF ObservableCollection<T> get ui reference from the added element -


i have encountered problem, have ui reference returned (after item has been added observablecollection). when item has been added collection, "border" reference.

been trying google solution cant find one.

the xaml, want return border in datatemplate (is possible)?

 <itemscontrol itemssource="{binding elements}">         <itemscontrol.itemspanel>             <itemspaneltemplate>                 <stackpanel margin="37,0,0,0" orientation="horizontal" horizontalalignment="left" width="590" height="29" />             </itemspaneltemplate>         </itemscontrol.itemspanel>         <itemscontrol.itemcontainerstyle>             <style targettype="{x:type contentpresenter}" />         </itemscontrol.itemcontainerstyle>         <itemscontrol.itemtemplate>             <datatemplate>                 <border width="{binding style.background.width}" margin="{binding style.background.position, converter={staticresource leftmarginconverter}}" borderthickness="{binding style.background.bordersize}" borderbrush="{binding style.background.bordercolor, converter= {staticresource mediabrushconverter}}" height="27" horizontalalignment="center" verticalalignment="center">                     <border.background>                         <lineargradientbrush gradientstops="{binding style.background.background, converter={staticresource gradientconverter}}" opacity="{binding style.background.opacity}"/>                     </border.background>                      <stackpanel orientation="horizontal" verticalalignment="center" horizontalalignment="center">                         <textblock text="{binding value}" fontfamily="{binding style.value.font, converter= {staticresource fontconverter}}" foreground="{binding style.value.fontcolor, converter= {staticresource mediabrushconverter}}" fontsize="{binding style.value.fontsize}" textalignment="center"  opacity="1" horizontalalignment="center" verticalalignment="center" />                         <textblock text="{binding textextension}" fontfamily="{binding style.value.font, converter= {staticresource fontconverter}}" foreground="#eaeaea" fontsize="{binding style.value.fontsize}" textalignment="center"  opacity="1" horizontalalignment="center" verticalalignment="center" />                     </stackpanel>                 </border>             </datatemplate>         </itemscontrol.itemtemplate>     </itemscontrol>           foreach(var x in elements) //  elemets = observablecollection          {             var =fcontrols.itemcontainergenerator.containerfromitem(x) border;              messagebox.show(i.tostring()); /// returns null         } 

unfortunately, observablecollection doesn't provide functionality want. may use itemscontrol.itemcontainergenerator.containerfromitem() obtain contentcontrol wraps datatemplate.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -