How to create UserControl which may contain other elements in C#/WPF -
i want create usercontrol (like itemscontrol) may contain more 1 elemets inside it.
i want use usercontrol this:
<local:myusercontrol margin="10,34,10,10" background="#ff202020"> <local:otherusercontrol background="#ff202020" selectedbackground="#ff303030" /> <local:otherusercontrol background="#ff202020" selectedbackground="#ff303030" /> <local:otherusercontrol background="#ff202020" selectedbackground="#ff303030" /> <local:otherusercontrol background="#ff202020" selectedbackground="#ff303030" /> <local:otherusercontrol background="#ff202020" selectedbackground="#ff303030" /> </local:myusercontrol>
what should write in xaml make works need? can give me example of code?
usercontrols (in wpf) render single child, child (depending on type of control use) can have child items. example, if added stackpanel user control stackpanel have multiple children.
all controls in wpf render single child unless control layout control grid
, stackpanel
, canvas
, dockpanel
etc...
here's example using stackpanel
:
<usercontrol x:class="drawing.views.bidform" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" > <stackpanel> <label fontweight="bold" horizontalcontentalignment="center" > item1</label> <label fontweight="bold" horizontalcontentalignment="center" >item2</label> </stackpanel> </usercontrol>
Comments
Post a Comment