MindFusion.Wpf Pack Programmer's Guide
Creating New Cell Template

New cell templates are created the same way as custom control templates - by creating a new .NET Style with TargetType set to CellPresenter. The Style should provide a setter for the Template property. The following XAML snippet illustrates how.

XAML  Copy Code

<Style TargetType="{x:Type planner:CellPresenter}">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type planner:CellPresenter}">
      ...
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

The style definition needs to be placed in the application's resources (App.xaml or Application.xaml).

More advanced scenarios can include several triggers, which supply different templates for cells in the different views. The Default Cell Template uses this technique to provide different templates for the cells in different views. Below is an example XAML code illustrating this.

XAML  Copy Code

<Style TargetType="{x:Type local:CellPresenter}">
  <Style.Triggers>

    <DataTrigger Binding="{Binding StyleKey, RelativeSource={RelativeSource Self}}" Value="Simple">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type local:CellPresenter}">

            <!-- The template for Timetable and Resource view cells goes here -->

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </DataTrigger>

    <DataTrigger Binding="{Binding StyleKey, RelativeSource={RelativeSource Self}}" Value="WithHeader">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type local:CellPresenter}">

            <!-- The template for SingleMonth, MonthRange, List and WeekRange view cells goes here -->

          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </DataTrigger>

  </Style.Triggers>
</Style>

For more information on how to create new templates, check the DualView sample.