c# - WPF Add new dependency property in Calendar -
i need in creating new dependency property, functionality same selecteddates.
the logic works: using selecteddates
select days, pressing top button "set" add new property value selecteddates, set color , write values into text document.
also, should possible read text document these dates. when run program set date 05.13.2015, 05.14.2015, 05.15.2015 should highlighted.
i need create new dependency property of can select different color highlight date , write text file. functionality same selecteddates.
(sorry bad english)
http://s57.radikal.ru/i155/1505/a4/7d10f56aa52e.png
style:
<resourcedictionary xmlns:local="clr-namespace:customcalendar" xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:primitives="clr- namespace:microsoft.windows.controls.primitives;assembly=wpftoolkit" xmlns:vsm="clr-namespace:system.windows;assembly=wpftoolkit"> <!--calendaritem--> <style x:key="calendaritemstyle" targettype="primitives:calendaritem"> <setter property="template"> <setter.value> <controltemplate targettype="primitives:calendaritem"> <controltemplate.resources> <!-- start: data template header button --> <datatemplate x:key="daytitletemplate"> <grid> <textblock fontweight="normal" fontfamily="arial" fontsize="13.4" foreground="#ff063b83" horizontalalignment="center" text="{binding}" margin="0,3,0,3" verticalalignment="center"/> </grid> </datatemplate> <!-- end: data template header button --> </controltemplate.resources> <grid name="part_root"> <grid.resources> <solidcolorbrush x:key="disabledcolor" color="#a5ffffff" /> </grid.resources> <vsm:visualstatemanager.visualstategroups> <vsm:visualstategroup x:name="commonstates"> <vsm:visualstate x:name="normal" /> <vsm:visualstate x:name="disabled"> <storyboard> <doubleanimation storyboard.targetname="part_disabledvisual" storyboard.targetproperty="opacity" to="1" duration="0" /> </storyboard> </vsm:visualstate> </vsm:visualstategroup> </vsm:visualstatemanager.visualstategroups> <border borderbrush="#d3dadb" borderthickness="3" background="{templatebinding background}" cornerradius="3"> <border> <grid> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="*"/> <columndefinition width="auto"/> </grid.columndefinitions> <grid.resources> <!-- start: previous button template --> <controltemplate x:key="previousbuttontemplate" targettype="button"> <grid cursor="hand"> <vsm:visualstatemanager.visualstategroups> <vsm:visualstategroup x:name="commonstates"> <vsm:visualstate x:name="normal" /> <vsm:visualstate x:name="mouseover"> <storyboard> <coloranimation storyboard.targetname="textcolor" storyboard.targetproperty="color" to="#ff73a9d8" duration="0" /> </storyboard> </vsm:visualstate> <vsm:visualstate x:name="disabled"> <storyboard> <doubleanimation storyboard.targetname="textcolor" storyboard.targetproperty="opacity" to=".5" duration="0" /> </storyboard> </vsm:visualstate> </vsm:visualstategroup> </vsm:visualstatemanager.visualstategroups> <rectangle fill="#11e5ebf1" stretch="fill" opacity="1"/> <grid> <path margin="4,0,0,0" height="10" width="6" verticalalignment="center" horizontalalignment="left" stretch="fill" data="m288.75,232.25 l283,236.625 l288.75,240.625" strokethickness="2"> <path.stroke> <solidcolorbrush x:name="textcolor" color="#ff063b83" /> </path.stroke> </path> <path x:name="textcolor2" margin="4,0,0,0" height="10" width="12" verticalalignment="center" horizontalalignment="left" stretch="fill" data="m283,236.625 l297,236.625" stroke="#ff063b83" strokethickness="2"/> </grid> </grid> </controltemplate> <!-- end: previous button template --> <!-- start: next button template --> <controltemplate x:key="nextbuttontemplate" targettype="button"> <grid cursor="hand"> <vsm:visualstatemanager.visualstategroups> <vsm:visualstategroup x:name="commonstates"> <vsm:visualstate x:name="normal" /> <vsm:visualstate x:name="mouseover"> <storyboard> <coloranimation storyboard.targetname="textcolor" storyboard.targetproperty="color" to="#ff73a9d8" duration="0" /> </storyboard> </vsm:visualstate> <vsm:visualstate x:name="disabled"> <storyboard> <doubleanimation storyboard.targetname="textcolor" storyboard.targetproperty="opacity" to=".5" duration="0" /> </storyboard> </vsm:visualstate> </vsm:visualstategroup> </vsm:visualstatemanager.visualstategroups> <rectangle fill="#11e5ebf1" stretch="fill" opacity="1"/> <grid> <path margin="0,0,4,0" height="10" width="6" verticalalignment="center" horizontalalignment="right" stretch="fill" data="m283,232.25 l288.75,236.625 l283,240.625" strokethickness="2"> <path.stroke> <solidcolorbrush x:name="textcolor" color="#ff063b83" /> </path.stroke> </path> <path margin="4,0,0,0" height="10" width="12" verticalalignment="center" horizontalalignment="left" stretch="fill" data="m283,236.625 l297,236.625" stroke="#ff063b83" strokethickness="2"/> </grid> </grid> </controltemplate> <!-- end: next button template --> <!-- start: header button template --> <controltemplate x:key="headerbuttontemplate" targettype="button"> <grid cursor="hand"> <vsm:visualstatemanager.visualstategroups> <vsm:visualstategroup x:name="commonstates"> <vsm:visualstate x:name="normal" /> <vsm:visualstate x:name="mouseover"> <storyboard> <coloranimation storyboard.targetname="textcolor" storyboard.targetproperty="color" to="#ff73a9d8" duration="0" /> </storyboard> </vsm:visualstate> <vsm:visualstate x:name="disabled"> <storyboard> <doubleanimation storyboard.targetname="buttoncontent" storyboard.targetproperty="opacity" to=".5" duration="0" /> </storyboard> </vsm:visualstate> </vsm:visualstategroup> </vsm:visualstatemanager.visualstategroups> <contentpresenter x:name="buttoncontent" content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}" horizontalalignment="{templatebinding horizontalcontentalignment}" verticalalignment="{templatebinding verticalcontentalignment}"> <textelement.foreground> <solidcolorbrush x:name="textcolor" color="#ff063b83"/> </textelement.foreground> </contentpresenter> </grid> </controltemplate> <!-- end: header button template --> </grid.resources> <rectangle fill="#ffededed" grid.columnspan="4" height="35"/> <!-- start: previous button content --> <button x:name="part_previousbutton" margin="4" grid.row="0" grid.column="0" template="{staticresource previousbuttontemplate}" height="20" width="20" horizontalalignment="left" focusable="false"/> <!-- end: previous button content --> <!-- start: header button content --> <button x:name="part_headerbutton" grid.row="0" grid.columnspan="3" template="{staticresource headerbuttontemplate}" horizontalalignment="center" verticalalignment="center" fontsize="17" focusable="false" fontweight="semibold" fontfamily="arial" foreground="#ff063b83"/> <!-- end: header button content --> <!-- start: next button content --> <button x:name="part_nextbutton" margin="4" grid.row="0" grid.column="2" height="20" width="20" horizontalalignment="right" template="{staticresource nextbuttontemplate}" focusable="false"/> <!-- end: next button content --> <!-- start: month content grid --> <grid x:name="part_monthview" grid.row="1" grid.columnspan="4" visibility="visible"> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> </grid.columndefinitions> </grid> <!-- end: month content grid --> <!-- end: year content grid --> <grid x:name="part_yearview" grid.row="1" grid.columnspan="3" visibility="hidden"> <grid.rowdefinitions> <rowdefinition height="*"/> <rowdefinition height="*"/> <rowdefinition height="*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> <columndefinition width="*"/> </grid.columndefinitions> </grid> <!-- end: year content grid --> </grid> </border> </border> <rectangle x:name="part_disabledvisual" opacity="0" visibility="collapsed" stretch="fill" strokethickness="1" radiusx="2" radiusy="2" stroke="{staticresource disabledcolor}" fill="{staticresource disabledcolor}"/> </grid> <controltemplate.triggers> <trigger property="isenabled" value="false"> <setter targetname="part_disabledvisual" property="visibility" value="visible" /> </trigger> <datatrigger value="year"> <datatrigger.binding> <binding path="displaymode"> <binding.relativesource> <relativesource mode="findancestor" ancestortype="{x:type toolkit:calendar}" /> </binding.relativesource> </binding> </datatrigger.binding> <setter targetname="part_monthview" property="visibility" value="hidden" /> <setter targetname="part_yearview" property="visibility" value="visible" /> </datatrigger> <datatrigger value="decade"> <datatrigger.binding> <binding path="displaymode"> <binding.relativesource> <relativesource mode="findancestor" ancestortype="{x:type toolkit:calendar}" /> </binding.relativesource> </binding> </datatrigger.binding> <setter targetname="part_monthview" property="visibility" value="hidden" /> <setter targetname="part_yearview" property="visibility" value="visible" /> </datatrigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!--calendardaybutton--> <style x:key="calendardaybuttonstyle" targettype="primitives:calendardaybutton"> <setter property="fontfamily" value="arial"/> <setter property="fontsize" value="12"/> <setter property="minwidth" value="5"/> <setter property="minheight" value="5"/> <setter property="horizontalcontentalignment" value="center"/> <setter property="verticalcontentalignment" value="center"/> <setter property="template"> <setter.value> <controltemplate targettype="primitives:calendardaybutton"> <controltemplate.resources> <lineargradientbrush x:key="gradient" endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="#fff9fafb" offset="0"/> <gradientstop color="#ffe9e9e9" offset="1"/> </lineargradientbrush> </controltemplate.resources> <grid> <rectangle x:name="background" grid.row="1" radiusx="1" radiusy="1" fill="{staticresource gradient}" /> <border> <contentpresenter x:name="normaltext" verticalalignment="{templatebinding verticalcontentalignment}" horizontalalignment="center"> </contentpresenter> </border> <rectangle x:name="border" strokethickness="0.2" grid.rowspan="2" snapstodevicepixels="true"> <rectangle.stroke> <solidcolorbrush x:name="borderbrush" color="#ff5d8cc9"/> </rectangle.stroke> </rectangle> </grid> <controltemplate.triggers> <trigger property="istoday" value="true"> <setter targetname="background" property="stroke" value="#ff063b83"/> <setter property="foreground" value="#ff063b83"/> </trigger> <trigger property="ismouseover" value="true"> <setter property="foreground" value="#ff5d8cc9"/> </trigger> <trigger property="isselected" value="true"> <setter targetname="background" property="fill" value="#bec9d7"/> </trigger> <trigger property="isinactive" value="true"> <setter targetname="background" property="fill" value="white"/> <setter property="foreground" value="#bdbdbd"/> </trigger> <trigger property="ispressed" value="true"> <setter targetname="background" property="fill" value="black"/> <setter property="foreground" value="#bdbdbd"/> </trigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style> <!--calendar--> <style targettype="local:mycalendar"> <setter property="calendaritemstyle" value="{staticresource calendaritemstyle}"/> <setter property="calendardaybuttonstyle" value="{staticresource calendardaybuttonstyle}" /> <setter property="template"> <setter.value> <controltemplate targettype="toolkit:calendar"> <grid name="part_root"> <primitives:calendaritem name="part_calendaritem" style="{templatebinding calendaritemstyle}" borderbrush="{templatebinding borderbrush}" borderthickness="{templatebinding borderthickness}"/> </grid> </controltemplate> </setter.value> </setter> </style> </resourcedictionary>
mycalendar.cs
namespace customcalendar { public class mycalendar : calendar { static mycalendar() { defaultstylekeyproperty.overridemetadata(typeof(mycalendar), new frameworkpropertymetadata(typeof(mycalendar))); } } }
Comments
Post a Comment