WPF ToolTip does not update

前端 未结 5 1386
孤城傲影
孤城傲影 2020-12-17 17:21

Assuming I have a simple class that represents a staff member

class Staff
{
    public string FirstName { get; set; }
    public string FamilyName { get; set         


        
5条回答
  •  遥遥无期
    2020-12-17 18:18

    In this particular case there is a cool trick you can use

    Seconds Alive Now = Seconds Alive originally + Elapsed Time

    You can bind to the Elapsed Time property and specify a converter that adds the initial value to it. That way you only need to raise 1 event and the tooltips would all be updated.

    Edit: You can add the ElapsedTime property (with INotifyPropertyChanged) to many places -- one logical place could be to the collection that is storing your Staff objects

    Edit: You would also need to bind each tooltip to the shared ElapsedTime property rather than the SecondsAlive property

提交回复
热议问题