What's the best idea for managing resources in Silverlight?

I need to create a silverlight framework that has all the resources for resources.

  • Partial loading. So, I cannot use the example resource file (*. Resx).
  • A strongly typed resource file. ... It's very easy to debug.
  • Easy to edit with a text editor. ... Because you cannot use any complex editor like visual studio on a web server.
  • It is easy to find missing resources.

prompt

My structure is based on the Visual Studio Integration Package project. Therefore I can change most of the Visual Studio features like editor, toolbar, menu.

Update # 1

If that's not possible, I'll create some resource edit on the web server to manage that resource.

Thanks,

0


a source to share


1 answer


I'm not sure what you are trying to do as your question was rather vague, but I can shed some light on how resources can be managed in the Silverlight platform.

Silverlight resources can be embedded in any XAML because all visuals have a ResourceDictionary accessible through the Resources property.

<Grid>
    <Grid.Resources>        

        <DataTemplate x:Key="MyTemplate">
        </DataTemplate>

    </Grid.Resources>
</Grid>

      

However, it is better to use special XAML files called Resource Dictionaries.

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

    <DataTemplate x:Key="MyTemplate">
    </DataTemplate>

</ResourceDictionary>

      

Silverlight 3 provides the ability to automatically merge these resource dictionaries into a dictionary of the main application resources.



<Application.Resources>
    <ResourceDictionary>

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resources/A.xaml"/>
            <ResourceDictionary Source="Resources/B.xaml"/>
            <ResourceDictionary Source="Resources/C.xaml"/>
        <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary>
<Application.Resources>

      

To combine the resource dictionary with your application resources, the resource dictionaries must be in a compressed XAP package that is used to deploy Silverlight applications to the client.

However, if you wanted, you could store the relational XAML resource stuff on a web server and cast it into your Silverlight application using a WebClient to download the file, and then using a XamlReader to create an in-memory object model from the XAML string you retrieve from file.

Resource dictionaries are inherently strongly typed, but not type safe. In this case, you will not get a compile-time error if there is an incorrectly typed element in the XAML. If there is an error in one of your resources, you will find that only when a reference to it is initialized and the rendering engine tries to instantiate your resource.

Shortly speaking:

  • Yes.
  • Yes.
  • Yes.
  • No.
+1


a source







All Articles