简体   繁体   English

如何在WPF中更改内容控件的Grid.Row和Grid.Column附加属性

[英]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. 我只需要使用双重动画来更改grid.Row和grid.Coloumspan和grid.coloumn属性。

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 一世

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM