wpf - Dependency Property doesnt trigger -
i have problem dependency properties. have been searching quite while "how tos" nothing me far.
i need grid change background color when drag it. here code far:
vb
friend shared readonly isdragoverpropertykey dependencypropertykey = dependencyproperty.registerreadonly("isdragover", gettype(boolean), _ gettype(ucpagecontrol), _ new propertymetadata(false)) public shared readonly isdragoverproperty dependencyproperty = isdragoverpropertykey.dependencyproperty private _isdragover boolean = true public property isdragover() boolean return cbool(getvalue(isdragoverproperty)) end set(byval value boolean) setvalue(isdragoverproperty, value) end set end property private sub grid_dragenter(sender object, e windows.drageventargs) isdragover = true end sub private sub grid_dragleave(sender object, e windows.drageventargs) isdragover = false end sub
xaml
<grid margin="0,0,216,63" dragenter="grid_dragenter" dragleave="grid_dragleave" mouseenter="grid_mouseenter_1" mouseleave="grid_mouseleave_1" allowdrop="true" > <grid.rowdefinitions> <rowdefinition></rowdefinition> </grid.rowdefinitions> <grid.style> <style targettype="grid"> <style.triggers> <trigger property="elements:ucpagecontrol.isdragover" value="false"> <setter property="background" value="white"></setter> </trigger> <trigger property="elements:ucpagecontrol.isdragover" value="true"> <setter property="background" value="black"></setter> </trigger> </style.triggers> </style> </grid.style> </grid>
somehow grid doesnt realize when property changes. here help?
create new class inherites grid , contains dependancy property. , use in xaml.
<controls:mygrid margin="0,0,216,63" dragenter="grid_dragenter" dragleave="grid_dragleave" mouseenter="grid_mouseenter_1" mouseleave="grid_mouseleave_1" allowdrop="true" > <controls:mygrid.rowdefinitions> <rowdefinition></rowdefinition> </controls:mygrid.rowdefinitions> <controls:mygrid.style> <style targettype="controls:mygrid"> <style.triggers> <trigger property="isdragover" value="false"> <setter property="background" value="white"></setter> </trigger> <trigger property="isdragover" value="true"> <setter property="background" value="black"></setter> </trigger> </style.triggers> </style> </controls:mygrid.style> </controls:mygrid>
Comments
Post a Comment