Click here to Skip to main content
15,893,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create multiple groups of control(s) within a rectangular border. where each group will be containing control within it, surrounded by rectangular border and a header (optional) is to be placed over each child group's top-left above its border. So, I created a class GroupLayout, each child element within this have to create its own new group. I created Header as an attached property.

Syntax making use of template is as:-

XML
<GroupLayout Orientation = "Vertical">
 <DataGrid GroupLayout.Header= "Group 1" />
 <Grid GroupLayout.Header= "Group 2" />
 -------So On--------
</GroupLayout>


as above given, DataGrid and Grid both should form there own two groups with vertical orientation. each child element should create its own new group. So, I tried this as User Control:-

XML
<Style TargetType = "GroupLayout">
 <setter.property>
   <controltemplate targettype="GroupLayout">
      <stackpanel>
        <border x:name="MainParentGroupBorder" xmlns:x="#unknown">
          <stackpanel>
            <contentpresenter content="{TemplateBinding HeaderLabel}" />
            <border x:name="ChildGroupBorder">
              <contentpresenter content="{TemplateBinding Content}" />
            </border>
          </stackpanel>
        </border>
      </stackpanel>
     </controltemplate>
   </setter.property>
  </Style>


In code behind I'm driving from ItemsControl. But, this is not working as required. I can't even implement ItemTemplate in Xaml here. because my template class is is a List, UIElements already have ItemTemplate defined, Can I override this ? or do need something else to do ?. Please help me, any answer would be appreciable.

Thanks,

GK Prajapati
Posted
Updated 25-Sep-13 8:39am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900