The object is an ListBoxItem, although I tried with a Panel as well.
I get this error message开发者_StackOverflow中文版: Property can not be null on Trigger.
, within an InvalidOperationException.
Here's the trigger:
<Trigger Property="IsInitialized" Value="true">
<Setter TargetName="MyPanel" Property="Background" Value="AliceBlue">
</Setter>
</Trigger>
Note: I can't use Loaded
, because I don't want it to fire whenever the control is rendered. Just at initializiation.
This property exists... why doesn't it work?
This is because the IsInitialized
property is not a Dependency Property. Triggers can only be used with dependency properties.
But the question is why would you need such a trigger? Because the same effect can be achieved just by specifying the Background
property directly on MyPanel
or in the style of `ListBoxItem'.
精彩评论