c# - Best WPF panel to create custom control -
i trying design custom control contains 1 rich text box , checkbox. need add control @ runtime in stack panel. since size of stack panel can change, want make sure custom control takes full space, , textbox inside control increases in size accordingly.
i getting bit confused panel best bet custom control. should go canvas or dockpanel, or maybe grid?
any suggestion welcome.
edit
below full code main page. contains 2 sections, 1 report preview, , report editing. report editing section count total subreports , create many sections. so, report editing pane needs stack controls nicely, , move other controls , down accommodate expansion of subreports. subreports can vary in size.
telerik's radexpander looked idea @ first, main stackpanel not consider radexpander's visibility state. right now, stackpanel uses full height when radexpander minimized.
<scrollviewer grid.row="1" panel.zindex="5"> <grid x:name="mainarea" verticalalignment="top"> <grid.columndefinitions> <columndefinition width="1*"/> <columndefinition width="1*"/> </grid.columndefinitions> <stackpanel canverticallyscroll="true" scrollviewer.verticalscrollbarvisibility="auto"> <telerik:radexpander x:name="reportsection" height="120" margin="10,10,10,10" verticalalignment="top" fontfamily="trebuchet ms" foreground="#ff0081a7" header="report section name" borderbrush="#ff0081a7" borderthickness="1"> <telerik:radexpander.content> <stackpanel> <checkbox x:name="addtoreport" content="add report" horizontalalignment="left" verticalalignment="top" width="150" height="30" verticalcontentalignment="center" borderbrush="#ff0081a7" foreground="#ff0081a7" ischecked="true" fontfamily="trebuchet ms" /> <telerik:radrichtextbox x:name="radrichtextbox" documentinheritsdefaultstylesettings="true" height="auto" horizontalscrollbarvisibility="hidden" isselectionminitoolbarenabled="true" isspellcheckingenabled="true" iscontextmenuenabled="true" margin="10" verticalscrollbarvisibility="auto" width="auto"/> </stackpanel> </telerik:radexpander.content> </telerik:radexpander> <telerik:radexpander x:name="reportsection2" height="120" margin="10,10,10,10" verticalalignment="top" fontfamily="trebuchet ms" foreground="#ff0081a7" header="report section name" borderbrush="#ff0081a7" borderthickness="1" verticalcontentalignment="top" horizontalcontentalignment="left" rendertransformorigin="0.493,0.856"> <telerik:radexpander.content> <stackpanel> <checkbox x:name="addtoreport2" content="add report" horizontalalignment="left" verticalalignment="top" width="150" height="30" verticalcontentalignment="center" borderbrush="#ff0081a7" foreground="#ff0081a7" ischecked="true" fontfamily="trebuchet ms" /> <telerik:radrichtextbox x:name="radrichtextbox2" documentinheritsdefaultstylesettings="true" height="auto" horizontalscrollbarvisibility="hidden" isselectionminitoolbarenabled="true" isspellcheckingenabled="true" iscontextmenuenabled="true" margin="10" verticalscrollbarvisibility="auto" width="auto"/> </stackpanel> </telerik:radexpander.content> </telerik:radexpander> <telerik:radexpander x:name="reportsection3" height="120" margin="10,10,10,10" verticalalignment="top" fontfamily="trebuchet ms" foreground="#ff0081a7" header="report section name" borderbrush="#ff0081a7" borderthickness="1"> <telerik:radexpander.content> <stackpanel> <checkbox x:name="addtoreport3" content="add report" horizontalalignment="left" verticalalignment="top" width="150" height="30" verticalcontentalignment="center" borderbrush="#ff0081a7" foreground="#ff0081a7" ischecked="true" fontfamily="trebuchet ms" /> <telerik:radrichtextbox x:name="radrichtextbox3" documentinheritsdefaultstylesettings="true" height="auto" horizontalscrollbarvisibility="hidden" isselectionminitoolbarenabled="true" isspellcheckingenabled="true" iscontextmenuenabled="true" margin="10" verticalscrollbarvisibility="auto" width="auto"/> </stackpanel> </telerik:radexpander.content> </telerik:radexpander> <telerik:radexpander x:name="reportsection4" height="120" margin="10,10,10,10" verticalalignment="top" fontfamily="trebuchet ms" foreground="#ff0081a7" header="report section name" borderbrush="#ff0081a7" borderthickness="1"> <telerik:radexpander.content> <stackpanel> <checkbox x:name="addtoreport4" content="add report" horizontalalignment="left" verticalalignment="top" width="150" height="30" verticalcontentalignment="center" borderbrush="#ff0081a7" foreground="#ff0081a7" ischecked="true" fontfamily="trebuchet ms" /> <telerik:radrichtextbox x:name="radrichtextbox4" documentinheritsdefaultstylesettings="true" height="auto" horizontalscrollbarvisibility="hidden" isselectionminitoolbarenabled="true" isspellcheckingenabled="true" iscontextmenuenabled="true" margin="10" verticalscrollbarvisibility="auto" width="auto"/> </stackpanel> </telerik:radexpander.content> </telerik:radexpander> </stackpanel> </grid> </scrollviewer>
answered before edit
based on explanation can exclude canvas list. others have resizing , repositioning capabilities child controls within them. possible have same behavior configuring 1 panel instance grid, have same effect panel dockpanel. gridpanel versatile, each , every panel has use. idea should use right panel job amount of xaml limited , readable.
more information on containers can found here : http://www.wpf-tutorial.com/panels/introduction-to-wpf-panels/
you did not give concrete question positioning answer can scratch surface too. if google around wpf panels , layouting , spend time read material , exercises sure you'll understand them in few hours of time.
Comments
Post a Comment