问题
Silverlight Toolkit has a resource file named Resources.resx, which contains "On" and "Off" string states for the switch. But when I have added a corresponding localized resource, Resources.ru-RU.resx, it wasn't picked up by the localization (though the similar approach works for my own resources).
One way to do it is to create my own binding for the ToggleSwitch Content, but I was hoping for a non-coding solution. Possible?
回答1:
You need to name your resource file ControlResources.ru-RU.resx , see Andrej Torzen's article on the subject.
回答2:
Localize ToggleSwitch in Silverlight Toolkit can be achived via DataTemplate
    <toolkit:ToggleSwitch x:Name="MySwitch" Header="Localized Switch">  
        <toolkit:ToggleSwitch.ContentTemplate>  
            <DataTemplate>  
                <ContentControl HorizontalAlignment="Left"   
                    Content="{Binding Converter={StaticResource Switch}}"/>  
            </DataTemplate>  
        </toolkit:ToggleSwitch.ContentTemplate>  
    </toolkit:ToggleSwitch>
Declare an ValueConverter:
    public class BoolToSwitchConverter : IValueConverter  
    {  
        private string FalseValue = Resources.Off;  
        private string TrueValue  = Resources.On;  
        public object Convert(object value, Type targetType, object parameter,
              System.Globalization.CultureInfo culture)  
        {  
            if (value == null)  
                return FalseValue;  
            else  
                return ("On".Equals(value)) ? TrueValue : FalseValue;  
        }  
        public object ConvertBack(object value, Type targetType, 
               object parameter, System.Globalization.CultureInfo culture)  
        {  
            return value != null ? value.Equals(TrueValue) : false;  
        }  
    }
More details here.
来源:https://stackoverflow.com/questions/7266875/how-to-localize-toggleswitch-on-windows-phone-7-localizing-silverlight-toolkit