【问题标题】:Convert from string to Thickness, GridLength, Brush... in UWP在 UWP 中从字符串转换为粗细、网格长度、画笔...
【发布时间】:2016-10-11 18:09:37
【问题描述】:

是否有内置类可以将字符串转换为常见类型?

例如,将“1,2,3,4”转换为Thickness 或将“#00AABBCC”转换为Brush。

【问题讨论】:

    标签: c# xaml uwp


    【解决方案1】:

    没有。 UWP 中没有用于Thickness 或Brush 的内置字符串转换器。

    但是here's 如何创建StringToSolidColorBrushConverter。

    还有here's.NET的System.Windows.ThicknessConverter的源代码。虽然它仅适用于 .NET Framework,但您可以从 FromString(..) 方法中获取转换器算法。

    【讨论】:

      猜你喜欢
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 2021-08-15
      • 1970-01-01
      • 2014-08-15
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      相关资源
      最近更新 更多