Customize the color scheme for a Silverlight application from an external resource

I have a Silverlight 3 application containing six user controls. I would like to download the color scheme for these controls from an external resource .

Code and XAML containing the default color scheme will be built in XAP. Then, the object tag parameter will contain a URL from which alternative colors can be dynamically loaded.

By the way, the Silverlight 3 application theme function can be used, if possible, but is actually too large. Only the colors need to be changed.

Is this possible and how would you recommend it?

+3
source share
2 answers

This is how I do it.

In App.xaml, I would define an application resource dictionary as follows: -

<Application.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="ColorTable.xaml" />
    </ReourceDictionary>
    <!-- rest of your application resource entries here -->
  </ResourceDictionary>
</Application.Resources>

Now I would put ColorTable.xaml outside of XAP in the same folder that XAP is in. This does not quite meet all your criteria, since an external ColorTable is always required. This can be minimized to achieve the full requirement, but it will be rather dirty in comparison.

0
source

I would take a look at the technique Corinne Barber uses in these two articles:
http://blogs.msdn.com/corrinab/archive/2009/11/24/9927729.aspx
http://blogs.msdn.com/corrinab/ archive / 2009/12/02 / 9931283.aspx

, , ( , ) ( SysColors). , : Background="{Binding CalendarGradient, Source={StaticResource SysColors}}"

, . ( xml - ). , xaml XamlReader.Load . , , .

WCF . INotiyPropertyChanged , , . , .

0

Source: https://habr.com/ru/post/1733109/


All Articles