WPF TwoWay Binding to a static class Property

前端 未结 3 2156
遥遥无期
遥遥无期 2020-12-01 20:25

There\'s no problem if Mode=OneWay, but I have this: Class:

namespace Halt
{
    public class ProjectData
    {
            public static string Username {ge         


        
3条回答
  •  广开言路
    2020-12-01 20:47

    If the binding needs to be two-way, you must supply a path. There's a trick to do two-way binding on a static property, provided the class is not static : declare a dummy instance of the class in the resources, and use it as the source of the binding.

    
        
    
    ...
    
    
    

提交回复
热议问题