Search code examples
silverlight-4.0headeraccordioncode-behindshow-hide

How to show or hide button in a datagrid header?


I am developing the silverlight application. I am new to the silverlight 4. I am using the following link for reference in my accordion control

http://forums.silverlight.net/forums/p/166937/376318.aspx

In the above link with AccordionItem.Header I am able to show or hide the button control but I am not able to handle the click event on the button control in code behind. So I have used the AccordionItem.HeaderTemplate in my code. I have 4 buttons in my header control. I am able to show and hide the button by using the above link. With HeaderTemplate I am able to handle the click event on the button control in code behind. With HeaderTemplate I am not able to access the button control placed inside HeaderTemplate in code behind. I am getting the NullReferenceException error "The Object reference not set to an instance of the object" How to resolve the above issue ? Can you please provide me any code or link through which I can access the control placed inside the HeaderTemplate in code behind ? If I am doing anything wrong then please guide me.


Solution

  • You can enable the button in the header of datagrid with the following statement in code behind

    accordiocntl.SelectionMode = AccordionSelectionMode.ZeroOrOne;
    

    You can refer the link https://forums.silverlight.net/forums/p/134010/301229.aspx for more details