Пример #1
0
        private static bool TryHandleLocalizationBinding(BindingExpression bindingExpression, PropertyInfo targetProperty, IValueConverter converter)
        {
            if (bindingExpression.Source.StartsWith("@"))
            {
                string locName  = bindingExpression.Source.Substring(1);
                string locValue = PortableLocalizedResources.GetString(locName);

                SetTargetProperty(locValue, bindingExpression.View, targetProperty, converter, bindingExpression.ConverterParameter);

                return(true);
            }

            return(false);
        }
Пример #2
0
        private static bool LocalizeProperty <T>(View view, Func <T, string> getOriginalText, Action <T, string> assignLocalizedText)
            where T : class
        {
            T castedView = view as T;

            if (castedView == null)
            {
                return(false);
            }

            string originalText = getOriginalText(castedView);

            if (originalText != null && originalText.Length > 2 && originalText[0] == '{' && originalText[originalText.Length - 1] == '}')
            {
                assignLocalizedText(castedView, PortableLocalizedResources.GetString(originalText.Substring(1, originalText.Length - 2)));
            }

            // Returning true indicates that the view was of the specified type, so that the caller can stop checking different types
            return(true);
        }