views:

2763

answers:

3

Hello,

I have an Accordion control to which I have added a datagrid.

The problem is that I cannot set the header of the accordian item that displays the Datagrid.

I can only set the header on the object of the class AccordionItem and not when the Datagrid is added to the Accordion.

I also tried to add the Datagrid to the Accordionitem object that was added to the Accordion but could not succeed. I can't figure out how to add Datagrid to accordonitem object.

Appreciate your help.

Thanks, I

A: 

An Accordion has only AccordionItem children. You should set the child explicitly to the Accordion like that (example of an Accordion with a StackPanel as a child and a template for the header):

<layoutToolkit:Accordion 
        x:Name="accordion" 
        ExpandDirection="Down" 
        HorizontalAlignment="Stretch" 
        HorizontalContentAlignment="Stretch" 
        SelectionChanged="Accordion_SelectionChanged" 
        AccordionButtonStyle="{StaticResource DateAccordionButtonStyle}" 
        Background="White"
        Padding="2"
        >
    <layoutToolkit:AccordionItem x:Name="dayAI" Background="{StaticResource OutlookCalendarColor}" >
        <layoutToolkit:AccordionItem.HeaderTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal" Margin="0,0,0,2">
                    <Image VerticalAlignment="Center" Source="{Binding Day, Source={StaticResource ImagesPath}}" Stretch="Uniform" />
                    <TextBlock FontWeight="Bold" VerticalAlignment="Center" Text="{Binding Resource.Day, Source={StaticResource LocalizedStrings}}" Margin="5,0,0,0" />
                </StackPanel>
            </DataTemplate>
        </layoutToolkit:AccordionItem.HeaderTemplate>
        <StackPanel >
            <RadioButton Margin="5,5,5,5" x:Name="todayRB" GroupName="RBGroup" Content="{Binding Resource.Today, Source={StaticResource LocalizedStrings}}" Checked="RB_Checked"/>
            <RadioButton Margin="5,5,5,5" x:Name="yesterdayRB" GroupName="RBGroup" Content="{Binding Resource.Yesterday, Source={StaticResource LocalizedStrings}}" Checked="RB_Checked"/>
            <RadioButton Margin="5,5,5,5" x:Name="dayPickerRB" GroupName="RBGroup"  Checked="RB_Checked">
                <StackPanel Orientation="Horizontal" >
                    <TextBlock Text="{Binding Resource.Day, Source={StaticResource LocalizedStrings}}" Margin="0,0,5,0" VerticalAlignment="Center"/>
                    <Controls:DatePicker x:Name="dayPickerDP" />
                </StackPanel>
            </RadioButton>
        </StackPanel>
    </layoutToolkit:AccordionItem>
</layoutToolkit:Accordion>

So in your case it would be something like:

<Accordion>
   <AccordionItem Header="My header text">
     <DataGrid x:Name="MyDataGrid"/>
   </AccordionItem>
</Accordion>

Hope that makes sense to you.

R4cOON
Perfect. Thanks so much.Some info here! http://forums.silverlight.net/forums/p/125308/286961.aspx#286961
A: 

The above answer from R2cOON works grea.

I also got answer here :

http://forums.silverlight.net/forums/p/125308/286961.aspx#286961

A: 

Is it only me? I cant get the AccordionItem.HeaderTemplate to show as attachable

Error The attachable property 'Header' was not found in type 'Accordion'.

Am I being really stupid here or has something changed?

Matthew Black

related questions