MindFusion.Wpf Pack Programmer's Guide
The Default Cell Template

Below is the complete XAML code of the default style of the cell presenter.

XAML  Copy Code

<!-- Static images -->
<BitmapImage x:Key="HiddenItemsImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/MoreDown.png" />
<BitmapImage x:Key="RecurrenceImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/Recurrence.png" />
<BitmapImage x:Key="RecurrenceExImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/RecurrenceEx.png" />
<BitmapImage x:Key="ReminderImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/Reminder.png" />
<BitmapImage x:Key="ArrowLeftImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/ArrowLeft.png" />
<BitmapImage x:Key="ArrowRightImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/ArrowRight.png" />
<BitmapImage x:Key="ArrowUpImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/ArrowUp.png" />
<BitmapImage x:Key="ArrowDownImage" UriSource="pack://application:,,,/MindFusion.Scheduling.Wpf;component/Resources/ArrowDown.png" />

<Style TargetType="local:CellPresenter">
  <Style.Triggers>

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

            <Border
              DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
              BorderBrush="{Binding CellStyle.BorderBrush}"
              BorderThickness="{Binding CellStyle.BorderThickness}"
              Background="{Binding Background}"
              Margin="{Binding CellMargin}" />

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

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

            <Border
              DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
              BorderBrush="{Binding CellStyle.BorderBrush}"
              BorderThickness="{Binding CellStyle.BorderThickness}"
              Background="{Binding Background}"
              Margin="{Binding CellStyle.Margin}">
              <Grid>
                <Border
                  BorderBrush="{Binding CellHeaderStyle.BorderBrush}"
                  BorderThickness="{Binding CellHeaderStyle.BorderThickness}"
                  Background="{Binding CellHeaderStyle.Background}"
                  Margin="{Binding CellHeaderStyle.Margin}"
                  Width="{Binding HeaderWidth}"
                  Height="{Binding HeaderHeight}"
                  VerticalAlignment="{Binding HeaderVerticalAlignment}"
                  HorizontalAlignment="{Binding HeaderHorizontalAlignment}" />
                <Border Visibility="{Binding Path=IsTodayCell, RelativeSource={RelativeSource TemplatedParent},
                  Converter={StaticResource visibleConverter}, ConverterParameter=true}"
                  Margin="{Binding CellHeaderStyle.Margin}"
                  Width="{Binding HeaderWidth}"
                  Height="{Binding HeaderHeight}"
                  VerticalAlignment="{Binding HeaderVerticalAlignment}"
                  HorizontalAlignment="{Binding HeaderHorizontalAlignment}">
                  <Border Visibility="{Binding Path=CellSettings.ShowToday, RelativeSource={RelativeSource TemplatedParent},
                    Converter={StaticResource visibleConverter}, ConverterParameter=true}"
                    BorderBrush="{Binding CellSettings.TodayBrush}"
                    BorderThickness="{Binding CellHeaderStyle.BorderThickness}"
                    Background="{Binding CellSettings.TodayFillBrush}">
                  </Border>
                </Border>
                <Border           
                  BorderThickness="{Binding CellHeaderStyle.BorderThickness}"          
                  Margin="{Binding CellHeaderStyle.Margin}"
                  Width="{Binding HeaderWidth}"
                  Height="{Binding HeaderHeight}"
                  VerticalAlignment="{Binding HeaderVerticalAlignment}"
                  HorizontalAlignment="{Binding HeaderHorizontalAlignment}">
                  <TextBlock
                    FontFamily="{Binding CellHeaderStyle.FontFamily}"
                    FontSize="{Binding CellHeaderStyle.FontSize}"
                    FontStretch="{Binding CellHeaderStyle.FontStretch}"
                    FontStyle="{Binding CellHeaderStyle.FontStyle}"
                    FontWeight="{Binding CellHeaderStyle.FontWeight}"
                    Foreground="{Binding CellHeaderStyle.Foreground}"
                    TextAlignment="{Binding CellHeaderStyle.TextAlignment}"
                    VerticalAlignment="{Binding CellHeaderStyle.VerticalAlignment}"
                    HorizontalAlignment="{Binding CellHeaderStyle.HorizontalAlignment}"
                    Margin="{Binding CellHeaderStyle.ContentMargin}"
                    Text="{Binding HeaderText}">
                    <TextBlock.LayoutTransform>
                      <RotateTransform Angle="{Binding HeaderTextRotation, FallbackValue=0}" />
                    </TextBlock.LayoutTransform>
                  </TextBlock>
                </Border>
                <Image Name="hiddenItemsCue" Source="{StaticResource HiddenItemsImage}" Margin="0,0,1,1" HorizontalAlignment="Right" Visibility="{Binding HiddenItemsCueVisibility}" VerticalAlignment="Bottom" Width="14" Height="7" Stretch="None" />
              </Grid>
            </Border>

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

  </Style.Triggers>
</Style>

The local namespace is defined as follows:

XAML  Copy Code

xmlns:local="clr-namespace:MindFusion.Scheduling.Wpf"

As can be seen in the above XAML, the style contains several triggers. Each trigger supplies a control template for the cells in different views. For example, the first trigger supplies the template of cells in the Resource and Timetable views. Those are the cells without headers. The trigger is activated when the value of the StyleKey property is set to "Simple".

XAML  Copy Code

<DataTrigger Binding="{Binding StyleKey, RelativeSource={RelativeSource Self}}" Value="Simple">
...

The next trigger supplies the template of cells that can have headers. Those are the cells in the SingleMonth, MonthRange, List and WeekRange views. The trigger is activated when the value of the StyleKey property is set to "WithHeader".

XAML  Copy Code

<DataTrigger Binding="{Binding StyleKey, RelativeSource={RelativeSource Self}}" Value="WithHeader">
...

The last trigger supplies the template for the cell representing the current day.

The following table illustrates the presentation of a cell in the three different templates:

Condition

Presentation

StyleKey=Simple

StyleKey=Today

StyleKey=WithHeader