views:

1076

answers:

1

So here's what I'm trying to do in a little nutshell, I'm just gonna start with code and it will most likely make sense.

 <bl:InnerGlowBorder x:Name="glow" InnerGlowColor="Teal">
            <bl:InnerGlowBorder.Style>
                <Style TargetType="bl:InnerGlowBorder">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ViewUnitStatus}"
                                     Value="UnitStatusModel.Pass">
                            <Setter Property="InnerGlowColor" Value="Green"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ViewUnitStatus}"
                                     Value="UnitStatusModel.Fail">
                            <Setter Property="InnerGlowColor" Value="Red"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ViewUnitStatus}" 
                                     Value="UnitStatusModel.Indeterminate">
                            <Setter Property="InnerGlowColor" Value="Yellow"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ViewUnitStatus}" 
                                     Value="UnitStatusModel.Warning">
                            <Setter Property="InnerGlowColor" Value="Orange"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </bl:InnerGlowBorder.Style>
        </bl:InnerGlowBorder>

And the enum definition:

namespace SEL.MfgTestDev.ESS.ViewModel
{
    public enum UnitStatusModel
    {
        Indeterminate,
        Pass,
        Fail,
        Warning,
    }
}

Am I missing a piece to make this work? I've found some WPF articles on enums that rely on object data sources and I don't really like that solution, isn't there something more simple I can do here?

A: 

I have found the solution and it was quite silly.

Styles are designed as a sort of visual template for a control, but they are designed as a base for visual implementation, not as a be-all/end-all visual model.

As a result, I had a situation in which my template dictated what the InnerGlowColor should be. However, by applying the attribute InnerGlowColor="Teal" to the element, I've created an override in effect, ignoring my visual style. The solution was to simply remove the dependancy property in the element declaration.

Firoso