private object BindDictionary(IServiceProvider serviceProvider)
        {
            string uid = _uid ?? GetUid(_target);
            string vid = _property.Name;

            Binding binding = new Binding("Dictionary");

            binding.Source = LanguageContext.Instance;
            binding.Mode   = BindingMode.TwoWay;
            LanguageConverter converter = new LanguageConverter(uid, vid, _default);

            if (_parameters.Count == 0)
            {
                binding.Converter = converter;
                object value = binding.ProvideValue(serviceProvider);
                return(value);
            }
            else
            {
                MultiBinding multiBinding = new MultiBinding();
                multiBinding.Mode      = BindingMode.TwoWay;
                multiBinding.Converter = converter;
                multiBinding.Bindings.Add(binding);
                if (string.IsNullOrEmpty(uid))
                {
                    Binding uidBinding = _parameters[0] as Binding;
                    if (uidBinding == null)
                    {
                        throw new ArgumentException("Uid Binding parameter must be the first, and of type Binding");
                    }
                }
                foreach (Binding parameter in _parameters)
                {
                    multiBinding.Bindings.Add(parameter);
                }
                object value = multiBinding.ProvideValue(serviceProvider);
                return(value);
            }
        }
Esempio n. 2
0
 public static void Binder(string id, string propname, string defvalue, DependencyObject depo, DependencyProperty depp)
 {
     Binding binding = new Binding("Dictionary");
     binding.Source = LanguageContext.Instance;
     LanguageConverter converter = new LanguageConverter(id, propname, defvalue);
     binding.Converter = converter;
     BindingOperations.SetBinding(depo, depp, binding);            
 }
Esempio n. 3
0
		private object BindDictionary(IServiceProvider serviceProvider)
		{
			string uid = _uid ?? GetUid(_target);
			string vid = _property.Name;

			Binding binding = new Binding("Dictionary");
			binding.Source = LanguageContext.Instance;
			binding.Mode = BindingMode.TwoWay;
			LanguageConverter converter = new LanguageConverter(uid, vid, _default);
			if (_parameters.Count == 0)
			{
				binding.Converter = converter;
				object value = binding.ProvideValue(serviceProvider);
				return value;
			}
			else
			{
				MultiBinding multiBinding = new MultiBinding();
				multiBinding.Mode = BindingMode.TwoWay;
				multiBinding.Converter = converter;
				multiBinding.Bindings.Add(binding);
				if (string.IsNullOrEmpty(uid))
				{
					Binding uidBinding = _parameters[0] as Binding;
					if (uidBinding == null)
					{
						throw new ArgumentException("Uid Binding parameter must be the first, and of type Binding");
					}
				}
				foreach (Binding parameter in _parameters)
				{
					multiBinding.Bindings.Add(parameter);
				}
				object value = multiBinding.ProvideValue(serviceProvider);
				return value;
			}
		}