WPF Getter/Setter Not Being Called

后端 未结 3 1450
感情败类
感情败类 2020-12-04 00:56

I have the following code. The PropertyChanged event is being called but the getter and setter is not. I can\'t for the life of me see why not. I have other properties where

3条回答
  •  离开以前
    2020-12-04 01:18

    I've found the reason why the getters and setters didn't appear to be firing. In my placement dependency property, I was setting the default value to PlacementMode.Right. WPF is ignoring the default value. I was then setting it to Placement="Right" in the XAML. Because this value was the same as the default, it was again ignored. By changing the default value to PlacementMode.Relative, I can now successfully set the value to "Right" in the XAML. This does prevent me from using Relative if I want, but I guess that could be solved by converting my properties to an object, which would then have a default of null.

提交回复
热议问题