WPF After a data trigger is in use (sealed), it cannot be modified
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
|
show 3 more comments
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
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
|
show 3 more comments
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
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
c# wpf visual-studio-2017
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
|
show 3 more comments
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
|
show 3 more comments
1 Answer
1
active
oldest
votes
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?
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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?
add a comment |
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?
add a comment |
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?
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?
answered Nov 21 '18 at 15:39
Kevin KouketsuKevin Kouketsu
362213
362213
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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