开发者

How to change the color of the blue border in the MS Silverlight Calendar Control?

开发者 https://www.devze.com 2023-02-04 01:41 出处:网络
At the top of the MS Silverlight Calendar control, it displays the month/year and some arrows for scrolling through those. Behind those items is a light blue rectangle. I\'d like to be able to change

At the top of the MS Silverlight Calendar control, it displays the month/year and some arrows for scrolling through those. Behind those items is a light blue rectangle. I'd like to be able to change the color of that rectangle. How would I go about doing that?

My first thought was to open the calendar control in Blend, choose to edit a template/copy 开发者_运维百科and just navigate to the correct control, but that path wasn't as obvious nor as possible as I had hoped. Opening a copy (template) of the control left me very little to work with. In fact, all it does is allow me to change the background (for the entire control, not just the month/year) and the border. Hmmm.

There are also options in the UI to edit the CalendarButtonStyle, CalendarDayButtonStyle and CalendarItemStyle. The CalendarItemStyle seems to be closest to what I want, but I'll be damned if I can figure out where that blue rectangle/border/panel/whatever is coming from?


The default background for the calendar control is actually a 4-stop linear gradient from top to bottom which provides the colors for both the light-blue background to the header and the white background to the rest of the calendar.

You actually don't need to template the control at all to tweak this background gradient. You can just set the background of the calendar to a LinearGradientBrush with the stops at an Offset of 0.16 (the default percentage where it changes from the header to the body of the calendar).

Here is an example in XAML changing the header background from the default of #FFD3DEE8 to black:

<controls:Calendar>
    <controls:Calendar.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="Black" Offset="0.16"/>
            <GradientStop Color="#FFFCFCFD" Offset="0.16"/>
            <GradientStop Color="White" Offset="1"/>
        </LinearGradientBrush>
    </controls:Calendar.Background>
</controls:Calendar>
0

精彩评论

暂无评论...
验证码 换一张
取 消