WPF Binding without path with converter, update

后端 未结 3 2076

I have a binding without path using a converter. This is because the converter will use many properties of the object to build the text for the tooltip. But when one property ch

3条回答
  •  天涯浪人
    2021-01-21 00:46

    One possible workaround is:

    Give your object a ItSelf property (or other name) like:

    public Object ItSelf
    {
        get { return this; }
    }
    

    Instead of binding

    {Binding Converter={StaticResource TooltipConverter}}
    

    use

    {Binding ItSelf, Converter={StaticResource TooltipConverter}}
    

    Then you raise OnPropertyChanged for ''ItSelf'' for every property. So you can signal an update for the whole object whenever it was used in a binding.

    public DateTime Start
    {
        get { return this.start; }
        set { this.start = value; OnPropertyChanged("Start"); OnPropertyChanged("ItSelf");
    }
    

    I got this to work a bit faster but would like to test out AttachedBehavior for this like stated by @AnatoliiG so I will accept an answer later.

提交回复
热议问题