【问题标题】:How to change the selected color of RadCalendar in Windows-Phone?如何在 Windows-Phone 中更改 RadCalendar 的选定颜色?
【发布时间】:2023-03-31 20:45:02
【问题描述】:

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

【问题讨论】:

    标签: xaml c#-4.0 telerik windows-phone-7.1


    【解决方案1】:

    您可以通过使用特殊模板来更改 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);
        }
    }
    

    您可以通过this thread了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 1970-01-01
      • 2013-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多