Search code examples
c#wpfwpf-controlspanel

How to change Grid.Row and Grid.Column attached property of content control in wpf


I am trying to build control similar as dock control. In my case,

I have Main Content, Side Content and Bottom Content.

Main content will be visible all the time which will be having data grid. on selection of data grid row, I need to display the details either in side Panel or Bottom Panle depdending on the mode user has selected. So control is same for side panel and bottom panel. It is just I need to change the grid.Row and grid.Coloumspan and grid.coloumn property using double animation.

Side Content and Bottom content will be in either case. If there is side mode, then side panel will be displaying the information but if there is bottom mode, then side panel control should be hooked to Bottom Content.

I


Solution

  • You can use

     Grid.SetRow(control, rowIndex);
    

    to change the row of a control, from code behind.

    If you want to use an animation to do it, see this code:

     <Storyboard>
             <Int32AnimationUsingKeyFrames Duration="0:00:05" Storyboard.TargetProperty="(Grid.Row)">
                     <LinearInt32KeyFrame KeyTime="0:0:00" Value="0"/>
                     <LinearInt32KeyFrame KeyTime="0:0:02" Value="1"/>
              </Int32AnimationUsingKeyFrames>
     </Storyboard>