首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Windows-Phone中更改RadCalendar的选定颜色?

如何在Windows-Phone中更改RadCalendar的选定颜色?
EN

Stack Overflow用户
提问于 2012-07-12 14:57:52
回答 1查看 1.2K关注 0票数 3

我在WindowsPhone应用程序中使用了Telerik的RadCalendar控件。我想在WindowsPhone的RadCalendar中更改SelectedDate的背景颜色...有什么方法可以改变这一点吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-15 04:04:42

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

代码语言:javascript
复制
<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>

用于周末的特殊模板示例

代码语言:javascript
复制
<?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}" />

现在模板选择器

代码语言:javascript
复制
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);
    }
}

您可以在this thread中了解更多信息。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11446487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档