3

我正在为我的 WindowsPhone 应用程序使用 Telerik 的 RadCalendar 控件。我想在 WindowsPhone 的 RadCalendar 中更改 SelectedDate 的背景颜色...有什么办法可以更改吗?

4

1 回答 1

3

您可以通过使用特殊模板来更改 SelectedDay 的属性。这是一天的示例数据模板:

<telerikInput:RadCalendar>
  <telerikInput:RadCalendar.ItemTemplate>
    <DataTemplate>
      <Grid Margin="5">
        <TextBlock Text="{Binding DetailText}" FontSize="7" MaxHeight="25" VerticalAlignment="Top" Margin="0,-2,0,0" />
        <TextBlock Text="{Binding Text}" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
      </Grid>
    </DataTemplate>
  </telerikInput:RadCalendar.ItemTemplate>
</telerikInput:RadCalendar>

周末特殊模板示例

<?xml version="1.0" encoding="utf-8"?>
<UserControl.Resources>
  <local:WeekendDaySelector x:Key="WeekendDaySelector">
    <local:WeekendDaySelector.SpecialTemplate>
      <DataTemplate>
        <Grid Margin="5">
          <Image Source="/Calendar/Images/SpecialDay.png" Width="24" Height="24" />
          <TextBlock Text="{Binding Text}" x:Name="TextPresenter" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
        </Grid>
      </DataTemplate>
    </local:WeekendDaySelector.SpecialTemplate>
  </local:WeekendDaySelector>
</UserControl.Resources>

<telerikInput:RadCalendar ItemTemplateSelector="{StaticResource WeekendDaySelector}" />

现在是模板选择器

public class WeekendDaySelector : DataTemplateSelector
{
    public DataTemplate SpecialTemplate
    {
        get;
          set;
    }

    public override DataTemplate SelectTemplate(object item, DependencyObject container)
    {
        CalendarButtonContentInfo info = item as CalendarButtonContentInfo;
          CalendarButton button = container as CalendarButton;
          if (!button.IsFromCurrentView) return null;
          if (info.Date == null) return null;
          if (info.Date.Value.DayOfWeek == DayOfWeek.Saturday ||
              info.Date.Value.DayOfWeek == DayOfWeek.Sunday)
          {
               return SpecialTemplate;
          }
          return base.SelectTemplate(item, container);
    }
}

您可以在此线程中了解更多信息。

于 2012-11-14T20:04:42.130 回答