0

我正在 UWP 中开发一个应用程序几个月了。我有一个问题,我正在努力为 UI 组件创建样式。到目前为止,我正在进行 API 调用,在其中我得到带有颜色列表的 json 响应(下面的代码)。然后我在我的 BaseViewModel 中有一个 Theme 对象,它是在 api 调用完成后设置的。我还使用数据绑定将 Theme 对象绑定到 xaml,以便显示颜色。根据我阅读的一篇文章,样式是在 App.xaml 中创建的,如下所述:UWP - 动态加载不同的 Styles.xaml。这就是我的问题所在,我想根据我在 ThemeModel(下面的代码)中收到的数据创建这些样式。

 <TextBlock
 x:Name="Count"
  FontSize="10"
 Foreground="{x:BindViewModel.Theme.DefaultColor,Converter={StaticResource   HexStringToSolidBrushConverter}, Mode=OneWay}"         
  Text="{x:Bind SymbolCount ,Mode=TwoWay}"
  HorizontalAlignment="Center"
  VerticalAlignment="Center"/>

任何建议将不胜感激。

 public class ThemeModel
 {
    public string DefaultColor { get; set; } 

    public string DefaultActionColor { get; set; }

    public string DefaultTextColor { get; set; } 

    public string DefaultTextDarkColor { get; set; }

    public string DefaultTextLightColor { get; set; }

    public string PrimaryColor { get; set; }

    public string PrimaryDarkestColor { get; set; }

    public string PrimaryDarkerColor { get; set; }

    public string PrimaryLighterColor { get; set; }

    public string PrimaryLightestColor { get; set; } 

    public string PrimaryActionColor { get; set; } 

    public string PrimaryTextColor { get; set; }

    public string PrimaryTextLightColor { get; set; }

    public string SecondaryColor { get; set; } 

    public string SecondaryDarkestColor { get; set; } 

    public string SecondaryDarkerColor { get; set; }

    public string SecondaryLightestColor { get; set; }

    public string SecondaryLighterColor { get; set; }

    public string SecondaryActionColor { get; set; }

    public string SecondaryTextColor { get; set; }

    public string SecondaryTextLightColor { get; set; }

    public string HueRedColor { get; set; }

    public string HueRedTextColor { get; set; }


}
4

0 回答 0