Windows Phone Controls 7で提供されているカレンダーを使用していると思います。コードプレックスのライブラリ。必要に応じてカレンダーをカスタマイズするには、コンバーターを実装し、それに IDateToBrushConverter を実装させる必要があります。このインターフェイスは、指定されたカレンダー ケースの背景または前景として使用するブラシを要求するためにカレンダーによって呼び出される単一の Method Convert を提供します。ここでの秘訣は、コンバーターのグローバル インスタンスを指定し、バックエンド Web サービスから返された日付を指定することです。たとえば、コンストラクターに挿入するか、静的メソッドとして指定します (これは好きではありません)。次に、Convert メソッドで、カレンダー ケースの日付が指定されたリスト内にあるかどうかを確認します。リスト内にある場合は、必要に応じて必要なブラシを返します。次に例を示します。
public class CalendarColorBackgroundConverter : IDateToBrushConverter
{
// ctor
public CalendarColorBackgroundConverter(IEnumerable<DateTime> datesToHighlight)
{
this.DatesToHighlight = datesToHighlight;
}
IEnumerable<DateTime> DatesToHighlight {get; private set;}
// some predefined brushes.
//static SolidColorBrush transparentBrush = new SolidColorBrush(Colors.Transparent);
static SolidColorBrush whiteColorBrush = new SolidColorBrush(Colors.White);
static SolidColorBrush selectedColorBrush = new SolidColorBrush(Colors.DarkGray);
static SolidColorBrush todayColorBrush = new SolidColorBrush(Color.FromArgb(255, 74, 128, 1));
static SolidColorBrush Foreground = new SolidColorBrush(Color.FromArgb(255, 108, 180, 195));
public Brush Convert(DateTime currentCalendarCaseDate, bool isSelected, Brush defaultValue, BrushType brushType)
{
var highlightDate = this.DatesToHighlight.Any(d => d.Year == currentCalendarCaseDate.Year && d.Month == currentCalendarCaseDateMonth.Month &&
d.Day == currentCalendarCaseDate.Day);
if (brushType == BrushType.Background)
{
if (highlightDate) // background brush color when the calendar case is selected
return todayColorBrush;
else
return whiteColorBrush;
}
else
{
if (highlightDate)
return whiteColorBrush;
return Foreground;
}
}
}
お役に立てれば。