Good practice passing data between 2 Silverlight 3 User Controls?
i total noob when comes silverlight 3 development , let me explain question using example. sake of simplicity let's have silverlight user control shows me grid customer information. have 2nd silverlight user control, again grid should display orders customer selected in 1st user control. have 3rd user control, let's call 1 main control, that hosts both user controls.
what want achieve content of order user controls automatically refreshed select customer customer user control.
is practice bubble event customer control main control , have main control update the order control? or how solve this?
you connect children events in parent (main) control. in maincontrol's code, can define children's object events pass data among controls.
customercontrol.xaml:
<grid>
<listbox x:name="listcustomers" />
</grid>
ordercontrol.xaml:
<grid>
<data:datagrid x:name="table" />
</grid>
mainpage.xaml:
<grid>
<grid.columndefinitions>
<columndefinition width="auto" />
<columndefinition width="*" />
</grid.columndefinitions>
<y:customercontrol x:name="customercontrol" grid.column="0" />
<y:ordercontrol x:name="ordercontrol" grid.column="1" />
</grid>
mainpage.xaml.cs:
public mainpage()
{
initializecomponent();
customercontrol.listcustomers.selectionchanged += new selectionchangedeventhandler(listcustomers_selectionchanged);
}
void listcustomers_selectionchanged(object sender, selectionchangedeventargs e)
{
ordercontrol.table.datacontext = (sender listbox).selecteditem;
}
Silverlight > Silverlight Controls and Silverlight Toolkit
Comments
Post a Comment