Main-phase/post-phase occur for animations where an element is being transitioned out of view.
The main-phase focuses on the primary animation for a column operation; for example, for hiding the column animation, the main-phase specifically involves the transition of the column from a visible state to a hidden state; because when you hide a column, the animation transitions the column out of view, its main-phase occurs simultaneously and usually ends ‘before’ the termination of the animation post-phase. The post-phase of the animation includes periphery elements, such as shifting displayed columns to fill in the space that was initially occupied by the now hidden column.
This example demonstrates the scenario with an animation consisting of a main-phase/post-phase, using the example of hiding a column.
-
Create an instance of the XamDataGrid
control with manually defined Column
objects for the FirstName, Sales, and Territory data. Note that the Sales column is visible in this example so that it can be hidden later using Column Hiding animation.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackLayout Orientation="Vertical" Grid.Row="0">
<Label Text="Is Column Hidden" />
<Switch x:Name="AnimationSwitch" IsToggled="False"/>
</StackLayout>
<ig:XamDataGrid x:Name="DataGrid" Grid.Row="1"
AutoGenerateColumns="False"
ColumnHidingAnimationMode="SlideToRightAndFadeOut">
<ig:XamDataGrid.ItemsSource>
<data:SampleSalesTeam />
</ig:XamDataGrid.ItemsSource>
<ig:XamDataGrid.Columns>
<ig:TextColumn PropertyPath="FirstName" />
<ig:TextColumn PropertyPath="Territory" />
<ig:NumericColumn PropertyPath="Sales"
IsHidden="{Binding Source={Reference AnimationSwitch}, Path=IsToggled}"/>
</ig:XamDataGrid.Columns>
<!-- TODO add ColumnAnimationSettings -->
</ig:XamDataGrid>
</Grid>
var column0 = new TextColumn();
column0.PropertyPath = "FirstName";
var column1 = new TextColumn();
column1.PropertyPath = "Territory";
var column2 = new NumericColumn();
column2.PropertyPath = "Sales";
column2.IsHidden = false;
DataGrid.Columns.Add(column0);
DataGrid.Columns.Add(column1);
DataGrid.Columns.Add(column2);
DataGrid.AutoGenerateColumns = false;
DataGrid.ItemsSource = new SampleSalesTeam();
DataGrid.ColumnHidingAnimationMode = ColumnHidingAnimationMode.SlideToRightAndFadeOut;
...
var AnimationSwitch = new Switch();
AnimationSwitch.IsToggled = false;
AnimationSwitch.Toggled += Switch_Toggled;
...
private void Switch_Toggled(object sender, ToggledEventArgs e)
{
DataGrid.Columns[2].IsHidden = e.Value;
}
-
Create an instance of GridColumnAnimationSettings type with custom parameters for main-phase and post-phase of the column hiding animation:
<ig.XamDataGrid.ColumnAnimationSettings>
<ig:GridColumnAnimationSettings>
<ig:GridColumnAnimationSettings.ColumnHidingMainPhase>
<ig:GridAnimationPhaseSettings DurationMilliseconds="2000"
HoldInitialMilliseconds="1000" />
</ig:GridColumnAnimationSettings.ColumnHidingMainPhase>
<ig.GridColumnAnimationSettings.ColumnHidingPostPhase>
<ig:GridAnimationPhaseSettings EasingFunctionType="CircleInOut"
DurationMillisecond="1000"/>
</ig.GridColumnAnimationSettings.ColumnHidingPostPhase>
</ig:GridColumnAnimationSettings>
</ig.XamDataGrid.ColumnAnimationSettings>
var settings = new GridColumnAnimationSettings();
settings.ColumnHidingMainPhase = new GridAnimationPhaseSettings
{
EasingFunctionType = GridEasingFunctionType.CircleInOut,
DurationMilliseconds = 2000,
HoldInitialMilliseconds = 1000,
};
settings.ColumnHidingPostPhase = new GridAnimationPhaseSettings
{
EasingFunctionType = GridEasingFunctionType.CircleInOut,
DurationMilliseconds = 1000,
};
...
DataGrid.ColumnAnimationSettings = settings;
-
Verify the result by running the application.
The following animated graphic demonstrates how hiding a column, using customized animation, works in XamDataGrid
control. The ColumnHidingAnimationMode
starts with the ColumnHidingMainPhase
which transitions the Sales column out of view by moving each of the column elements to the right margin of the column, where they all become increasingly transparent at the same time. Then the ColumnHidingPostPhase
of animation starts and the remaining columns are now repositioned, so that they occupy the space, made available by hiding the Sales column.
Related Content
The following table lists topics that are related to this topic:
Topic |
Purpose |
|
This topic provides information on supported column types in the XamDataGrid control.
|
|
This topic provides code examples on working with columns in the XamDataGrid control.
|