c# - Border.IsMouseOver in RichTextBox ( InlineUIContainer in RichTextBox does not respond to event/trigger ) -
say have following:
<grid> <grid.resources> <style targettype="{x:type border}"> <style.triggers> <trigger property="border.ismouseover" value="true"> <setter property="background" value="black" /> <setter property="borderbrush" value="red" /> <setter property="borderthickness" value="2" /> <setter property="cornerradius" value="7,2,10,2" /> </trigger> <trigger property="border.ismouseover" value="false"> <setter property="background" value="black" /> <setter property="borderbrush" value="royalblue" /> <setter property="borderthickness" value="2" /> <setter property="cornerradius" value="7,2,10,2" /> </trigger> </style.triggers> </style> <style targettype="{x:type textblock}"> <setter property="margin" value="7,0,7,1" /> <setter property="fontsize" value="12" /> <setter property="foreground" value="white" /> </style> <style targettype="{x:type run}"> <setter property="fontsize" value="12" /> </style> </grid.resources> <flowdocument > <paragraph> <span> <border> <textblock>test</textblock> </border> </span> </paragraph> </flowdocument> </richtextbox> </grid>
the style triggers work beautifully when border outside of richtextbox, not when inside inlineuicontainer in richtextbox.
i able desired behavior setting properties in code behind use of mouseover event , using visualtreehelper.hittest() method, i'm pretty sure terribly inefficient , can't think there better way approach this?
if offer guidance here, appreciated.
i had search deepest , darkest corners of internet find one, looks there hack enable events inlineuielements within flowdocument:
public class eventenabledflowdocument : flowdocument { protected override bool isenabledcore { { return true; } } }
note there nasty side effects doing this, seems work purposes. 1 side effect aware of - event handlers not saved if delete inlineuielement , undo deletion.
Comments
Post a Comment