Intersoft ClientUI Documentation
ObservableResource<T> Class
Members 



The type of the resource to observe.
Represents an observable resource which automatically updates UI elements when the value of its resource has changed.
Syntax
Public Class ObservableResource(Of T) 
   Implements IObservableResource 
Dim instance As ObservableResource(Of T)
public class ObservableResource<T> : IObservableResource  
generic<typename T>
public ref class ObservableResource : public IObservableResource  
Type Parameters
T
The type of the resource to observe.
Remarks

At the heart of the ClientUI Localization Framework are the LocalizationManager and ObservableResource<T> classes. The LocalizationManager contains the core implementation that processes the culture changes and consequently notifies the active observable resources. The ObservableResource<T> class implements IObservableResource interface to provide capability to track and monitor whether a localized resource has changed, which automatically updates the source elements on which the resource was bound to.

The first step to get started with ClientUI Localization Framework is to create an observable resource that wraps the resource assets in your application. Before continuing, you will need to configure your Silverlight or WPF project to support multiple cultures. For more information on creating localizable Silverlight project, see Walkthrough: Create a Localizable Silverlight Project.

You define one observable resource for each resource asset in your application, which is generally classified as the model in an MVVM application. To define an observable resource, you create a new class that derives from ObservableResource<T> and specify the type of the resource that you would like to observe, and finally create a constructor that pass-in a new instance of the localized resource class.

The following code shows how to create a new observable resource class that encapsulates an existing resource asset.

CS
Copy Code
public class MyAppResource : Intersoft.Client.Framework.ObservableResource<Resources>
{
    public MyAppResource()
        : base(new Resources())
    {
    }
}

Consuming the observable resource class in your XAML page is easy and straighforward. You create the mapping to the namespace that contains the observable resource class and define it as a static resource in the Resources of your XAML page.

The following code shows how to bind a simple TextBlock to the localized TodayText resource.

XAML
Copy Code
<Intersoft:UXPage 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:Models="clr-namespace:ClientUILocalizationManager.Models">
        
        <Intersoft:UXPage.Resources>

                <Models:MyAppResource x:Key="AppResource"/>

        </Intersoft:UXPage.Resources>

        <StackPanel>
                <TextBlock Text="{Binding Resource.TodayText, Source={StaticResource AppResource}}">
        </StackPanel>

</Intersoft:UXPage>

With the observable resource class defined as a static resource in the top most Resources of the page hierarchy, you can bind the UI elements to the desired localized string by using the {Binding} declaration. To learn more about data binding, see Data Binding Overview.

For more information about building localizable applications using ClientUI, see Localization Overview.

Inheritance Hierarchy

System.Object
   Intersoft.Client.Framework.ObservableResource<T>
      Intersoft.Client.UI.Aqua.UXInput.UXFileUploadResource
      Intersoft.Client.UI.Data.UXDataComboBoxResource
      Intersoft.Client.UI.Data.UXDataPagerResource
      Intersoft.Client.UI.Data.UXGridViewResource
      Intersoft.Client.UI.DocumentViewers.DocumentViewerResource
      Intersoft.Client.UI.Editors.UXPropertyGridResource
      Intersoft.Client.UI.Editors.UXQueryBuilderResource
      Intersoft.Client.UI.ScheduleView.UXScheduleViewResource

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ObservableResource<T> Members
Intersoft.Client.Framework Namespace

Send Feedback