data-binding - WindowsRT 数据绑定(bind)如何在没有 TypeConverterAttribute 的情况下进行类型转换

标签 data-binding windows-runtime windows-store-apps typeconverter

在上一个问题/答案中,我了解了 Windows Phone 中的数据绑定(bind)如何为 string 进行类型转换。至ImageSource使用 TypeConverterAttribute - 见 https://stackoverflow.com/a/16753488/373321

我现在正在查看 TypeConverterAttribute 的 WindowsStore 应用程序中的相同问题。 doesn't exist .

如果我使用 WinRT 数据绑定(bind),那么显然数据绑定(bind)层仍然可以进行正确的转换。 MSDN documentation说:

this behavior relies on underlying type conversion that processes the string as a URI, and calls the equivalent of the BitmapImage(Uri) constructor.



但是,我在任何地方都看不到任何关于它如何知道要进行什么转换的元数据。

我正在尝试构建自己的数据绑定(bind)实现——因此能够模仿 WinRT 的功能将非常有用。

是否有可查询的元数据提示告诉 Xaml 数据绑定(bind)应用什么转换?或者这是 stringImageSource转换以某种方式烘焙到运行时,隐藏在 CLR 层中?

如果它是隐藏的,是否有任何已知自动类型转换的列表,以便我可以将它们缓存在我的数据绑定(bind)实现中?

最佳答案

我通过 Twitter 与一位 WinRT 开发人员 (Tim Heuer) 讨论了这个问题

这次谈话的基本总结是:

  • WinRT 没有像 TypeConverterAttribute 这样的东西。
  • 少数 WinRT 控件确实有少量内部转换,它们将应用
  • 没有关于这些是哪些控制和转换的公开信息
  • 关于data-binding - WindowsRT 数据绑定(bind)如何在没有 TypeConverterAttribute 的情况下进行类型转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17220538/

    相关文章:

    .net - 如何将 WPF 绑定(bind)与relativesource 结合使用?

    c# - WinForms MVP 是否有另一种方法可以将数据绑定(bind)到 View 而无需 Presenter 访问 View 控件?

    c# - 无法将类型为 'Windows.UI.Xaml.Controls.Canvas' 的对象转换为类型 'Canvas'

    c# - 从 App WinRT 获取本地文件夹

    MediaElement.Stop 在 Windows 应用商店应用程序中播放实时流媒体源时不起作用

    windows-store-apps - 如何重命名 Windows 开发人员中心中已发布的应用程序?

    c# - ListView和AppBar的合作。最简单的多选场景

    javascript - 如何在 emberjs 上使用单向绑定(bind)?

    winrt 中的 C# gpgpu

    C#/WPF : Binding to an element outside of the visual/logical tree