Is it possible to bind to a ValueTuple field in WPF with C#7

前端 未结 3 769
慢半拍i
慢半拍i 2020-12-18 18:58

If I have a viewmodel property

public (string Mdf, string MdfPath) MachineDefinition { get; set; }

and I try to bind to it in XAML / WPF

3条回答
  •  旧时难觅i
    2020-12-18 19:41

    The MdfPath approach will never work, since the name part is very restrictive in terms of where it actually exists. Essentially, it is pure compiler voodoo, and doesn't exist in the type model, which means that anything that talks to the type model (which includes reflection, UI tools, serializers, etc) will only see the Item1, Item2 names; not the fake names.

提交回复
热议问题