c# - scope of element names in XAML -
i'm trying name , set datacontext combobox that's embedded within itemscontrol.
in main window, can access itemscontrol name not of elements within itemscontrol.
public mainwindow() { initializecomponent(); slist.datacontext = app.sclist; //this valid sts.datacontext = app.stlist; //this not }
and here's xaml code. can access slist within program not "sts" or "spanel1". compiler error is: "the name 'sts' not exist in current context"
note i've tried both "name" , "x:name"
<scrollviewer verticalscrollbarvisibility="auto" > <itemscontrol name ="slist" itemssource ="{binding}"> <itemscontrol.itemspanel> <itemspaneltemplate> <wrappanel margin="12"/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <border borderbrush="black" borderthickness="3" cornerradius="5" margin="8,8" cliptobounds="true" background="beige"> <stackpanel name="spanel1"> <stackpanel orientation="horizontal"> <label content="s type"/> <combobox name ="sts" itemssource="{binding path=shiptype.typename, mode=twoway}" datacontext="stlist"> </combobox> </stackpanel> <stackpanel orientation="horizontal"> <label content="class name"/> <textbox text="{binding path = name, mode=twoway}" horizontalalignment="center" fontweight="bold" /> </stackpanel> </stackpanel> </border> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </scrollviewer>
Comments
Post a Comment