WPF After a data trigger is in use (sealed), it cannot be modified












0















I have no idea what is wrong, and how I am supposed to solve the error. Strangely enough, the data triggers work fine.



    <Style TargetType="Border">
<Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ErrorState}">
<Setter Property="Background" Value="OrangeRed"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ProductionState}">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>


ProductionState and Error states are enum values referenced in XAML:



    <machineControl:MachineControllerState x:Key="ErrorState">Error</machineControl:MachineControllerState>
<machineControl:MachineControllerState x:Key="ProductionState">Production</machineControl:MachineControllerState>


The State binding references to the view model which is "a normal" property which supports IPropertyChanged (from mvvm lights lib)



    public MachineControllerState State
{
get => state;
set { Set(() => State, ref state, value); }
}


visual studio shows the error in error list:




After a data trigger is in use (sealed), it cannot be modified




Update: to be clear, the solution compiles fine, and runtime everything works as expected.










share|improve this question

























  • Is that VS2013?

    – Prateek Shrivastava
    Nov 21 '18 at 8:45











  • Oh sorry. Vs2017 latest update

    – bas
    Nov 21 '18 at 8:58











  • Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

    – Prateek Shrivastava
    Nov 21 '18 at 9:00











  • The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

    – Hans Passant
    Nov 21 '18 at 9:30








  • 1





    @KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

    – bas
    Nov 21 '18 at 15:36


















0















I have no idea what is wrong, and how I am supposed to solve the error. Strangely enough, the data triggers work fine.



    <Style TargetType="Border">
<Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ErrorState}">
<Setter Property="Background" Value="OrangeRed"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ProductionState}">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>


ProductionState and Error states are enum values referenced in XAML:



    <machineControl:MachineControllerState x:Key="ErrorState">Error</machineControl:MachineControllerState>
<machineControl:MachineControllerState x:Key="ProductionState">Production</machineControl:MachineControllerState>


The State binding references to the view model which is "a normal" property which supports IPropertyChanged (from mvvm lights lib)



    public MachineControllerState State
{
get => state;
set { Set(() => State, ref state, value); }
}


visual studio shows the error in error list:




After a data trigger is in use (sealed), it cannot be modified




Update: to be clear, the solution compiles fine, and runtime everything works as expected.










share|improve this question

























  • Is that VS2013?

    – Prateek Shrivastava
    Nov 21 '18 at 8:45











  • Oh sorry. Vs2017 latest update

    – bas
    Nov 21 '18 at 8:58











  • Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

    – Prateek Shrivastava
    Nov 21 '18 at 9:00











  • The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

    – Hans Passant
    Nov 21 '18 at 9:30








  • 1





    @KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

    – bas
    Nov 21 '18 at 15:36
















0












0








0








I have no idea what is wrong, and how I am supposed to solve the error. Strangely enough, the data triggers work fine.



    <Style TargetType="Border">
<Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ErrorState}">
<Setter Property="Background" Value="OrangeRed"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ProductionState}">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>


ProductionState and Error states are enum values referenced in XAML:



    <machineControl:MachineControllerState x:Key="ErrorState">Error</machineControl:MachineControllerState>
<machineControl:MachineControllerState x:Key="ProductionState">Production</machineControl:MachineControllerState>


The State binding references to the view model which is "a normal" property which supports IPropertyChanged (from mvvm lights lib)



    public MachineControllerState State
{
get => state;
set { Set(() => State, ref state, value); }
}


visual studio shows the error in error list:




After a data trigger is in use (sealed), it cannot be modified




Update: to be clear, the solution compiles fine, and runtime everything works as expected.










share|improve this question
















I have no idea what is wrong, and how I am supposed to solve the error. Strangely enough, the data triggers work fine.



    <Style TargetType="Border">
<Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ErrorState}">
<Setter Property="Background" Value="OrangeRed"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="{StaticResource ProductionState}">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
</Style.Triggers>
</Style>


ProductionState and Error states are enum values referenced in XAML:



    <machineControl:MachineControllerState x:Key="ErrorState">Error</machineControl:MachineControllerState>
<machineControl:MachineControllerState x:Key="ProductionState">Production</machineControl:MachineControllerState>


The State binding references to the view model which is "a normal" property which supports IPropertyChanged (from mvvm lights lib)



    public MachineControllerState State
{
get => state;
set { Set(() => State, ref state, value); }
}


visual studio shows the error in error list:




After a data trigger is in use (sealed), it cannot be modified




Update: to be clear, the solution compiles fine, and runtime everything works as expected.







c# wpf visual-studio-2017






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 12:13







bas

















asked Nov 21 '18 at 8:42









basbas

7,540104897




7,540104897













  • Is that VS2013?

    – Prateek Shrivastava
    Nov 21 '18 at 8:45











  • Oh sorry. Vs2017 latest update

    – bas
    Nov 21 '18 at 8:58











  • Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

    – Prateek Shrivastava
    Nov 21 '18 at 9:00











  • The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

    – Hans Passant
    Nov 21 '18 at 9:30








  • 1





    @KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

    – bas
    Nov 21 '18 at 15:36





















  • Is that VS2013?

    – Prateek Shrivastava
    Nov 21 '18 at 8:45











  • Oh sorry. Vs2017 latest update

    – bas
    Nov 21 '18 at 8:58











  • Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

    – Prateek Shrivastava
    Nov 21 '18 at 9:00











  • The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

    – Hans Passant
    Nov 21 '18 at 9:30








  • 1





    @KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

    – bas
    Nov 21 '18 at 15:36



















Is that VS2013?

– Prateek Shrivastava
Nov 21 '18 at 8:45





Is that VS2013?

– Prateek Shrivastava
Nov 21 '18 at 8:45













Oh sorry. Vs2017 latest update

– bas
Nov 21 '18 at 8:58





Oh sorry. Vs2017 latest update

– bas
Nov 21 '18 at 8:58













Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

– Prateek Shrivastava
Nov 21 '18 at 9:00





Shouldnt be the case then. Try Clean And Rebuild entire Solution. As others say that works for them - clearing the Error.

– Prateek Shrivastava
Nov 21 '18 at 9:00













The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

– Hans Passant
Nov 21 '18 at 9:30







The phrasing is not very helpful, it strikes me that "committed" would be a bit more helpful than "sealed". But at the root the xaml does not interact well with the code you wrote. Seems it wants to tinker with the trigger. We can't see the code. Temporarily commenting out stuff might well be a decent way to locate it.

– Hans Passant
Nov 21 '18 at 9:30






1




1





@KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

– bas
Nov 21 '18 at 15:36







@KevinKouketsu {x:Static machineControl:MachineControllerState.Production} is the fix. thx! a nicer look this way w/o errors :). Drop it as answer and i'll accept it

– bas
Nov 21 '18 at 15:36














1 Answer
1






active

oldest

votes


















1














You can refer your enum directly from your codebehind. Something like:



{x:Static namespacename:EnumName.EnumValue}



Reference:
How can I use enum types in XAML?






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408140%2fwpf-after-a-data-trigger-is-in-use-sealed-it-cannot-be-modified%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can refer your enum directly from your codebehind. Something like:



    {x:Static namespacename:EnumName.EnumValue}



    Reference:
    How can I use enum types in XAML?






    share|improve this answer




























      1














      You can refer your enum directly from your codebehind. Something like:



      {x:Static namespacename:EnumName.EnumValue}



      Reference:
      How can I use enum types in XAML?






      share|improve this answer


























        1












        1








        1







        You can refer your enum directly from your codebehind. Something like:



        {x:Static namespacename:EnumName.EnumValue}



        Reference:
        How can I use enum types in XAML?






        share|improve this answer













        You can refer your enum directly from your codebehind. Something like:



        {x:Static namespacename:EnumName.EnumValue}



        Reference:
        How can I use enum types in XAML?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 15:39









        Kevin KouketsuKevin Kouketsu

        362213




        362213






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408140%2fwpf-after-a-data-trigger-is-in-use-sealed-it-cannot-be-modified%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]