开发者

DataBinding using helper class in Silverlight 4 Error

I am new to the whole Silverlight thing. And got a problem

I have a class derrived from Binding the Localizer, which is declared like this:

public class Localizer : Binding
{
    public Localizer()
    {
    }

    private string _key;

    /// <summary>
    /// Localization key manager.
    /// </summary>
    public string Key
    {
        get { return _key; }
        set
        {
            _key = value;

           开发者_如何学Go Source = LocalizationHelper.Current;
            Path = new PropertyPath("Translations["+_key+"]");
        }
    }
}

When I am using it in the XAML page

<p:BasePage x:Class="Project.Pages.Desktop"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
xmlns:h="clr-namespace:Project.Helpers">   

<TextBlock Controls:DockPanel.Dock="Top" Text="{h:Localizer Key=UI_DSKTP_NAME}"/>  

I got an error

Type 'h:Localizer' is used like a markup extension but does not derive from MarkupExtension.    

This error allow the project to compile, and binding works, but it is anoying. Can you help me resolve this?


The use of {Binding} and other such markup extensions are hard-wired into the Xaml parser. You cannot "roll your own".

It seems to me that you are attempting to create a Localisation framework in you Silverlight app. See answers to this question Best Practices For Silverlight Localization?.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜