Why can't I use styles to set ControlTemplate properties conditionally? #31332
Replies: 1 comment 1 reply
-
From mucking around with a similar error, it seems like maybe this is Hot Reload related? I was having the same problem in a different situation, but I had 3 different styles doing the same thing and only ONE of them was not working. That was the last one I had updated in Hot Reload, so I turned off Hot Reload. That made Visual Studio crash so I restarted it. Clean build. Rebuild. Deploy. Debug. This time I got an exception when the page loaded: a silly typo in one of my resource names. If that was the cause of this, I don't understand why XAML can be smart enough to specifically tell me what name is missing when Hot Reload is disabled, but when Hot Reload is present it can only say "WhOA I don't know what StaticResource is duder". Or why I have to turn off hot reload, clean, rebuild, redeploy, THEN debug to work with an iOS project. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I made a Reddit post about this and got nothing useful, I'm hoping someone here can help me. Since making that post I've found a new situation where this occurs.
The original context is a page where I would like to make some changes to a lot of elements when the user is in landscape orientation on a phone. In code-behind, I'm using
DeviceDisplay
and its events to keep anIsVerticallyConstrained
dependency property up to date. (I just became aware of AdaptiveTrigger, but the components I'm working with aren't really using Visual State Manager so let's stick with this.)For one component, I figured I could change templates based on the property and I had this rough XAML structure:
In other parts of the page I'm doing this for simpler properties like
FontSize
and it works. Here I can tell the data trigger is happening, but I get this error in the output:For some reason, in this situation, the
Setter
is not resolving the static resource extension. But I have many other styles that do this successfully, for example:This does not cause any errors and behaves as expected.
I don't understand what specifically is happening in the first case. I can't say it's a bug because there may be some twist in the behavior I'm not aware of. But I'd like to know what's going on if this isn't expected to work.
Beta Was this translation helpful? Give feedback.
All reactions