Inheriting styles in custom WPF controls

I have a datagrid, and certain columns need to contain text that is linked to a detail window. So, in order to make it a bit easier on myself, I created a UserControl that is basically a Button with a control template that contains a TextBlock (I could have done this a number of other ways, I know, but I figured the button already exposes a Click event, so why not?). Things are getting a bit hairy, though, when it comes to styling: I'd like to give the text a "hyperlink" sort of format--blue text, underlined--so that it's clear they are links (also, so that they resemble to format in the legacy WinForms application I'm re-implementing). But I would also like to be able to style the text--ideally, it should grab things like text color if text color is set in a style on the parent cell.

Basically, is there an easy way to implement a custom UserControl that will a) grab styles from a parent element and b) apply its default styles in a low-priority way, i.e. only apply a specific style if there's not already one set from the parent? I know I can pass the parent's style manually through a binding, but I was wondering if there was an easier way.

Answers


It sounds like you need to create a true Control or ContentControl implementation for this, so that you can override the true styles and templates.

UserControls are not really stylable, unless you start somehow creating custom properties for binding Styles.. but none of that will be implicit.


Need Your Help

Does EBean (4.5.x) support mapping Java 8's time types such as OffsetDateTime

java playframework java-8 ebean

There is a closed ticket suggesting that Ebean 4.4.1 and onwards supports Java 8's time classes, such as OffsetDateTime. However, I can't find any Ebean documentation showing the use these classes....

set static member pointer variables

c++ static-variables class-variables

I'm trying to set a static pointer variable in a class but I'm getting these errors for each variable I try to set.