protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Type actualType, FrameworkElement attachedObject) { DependencyProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); if (dependencyProperty == null) { Mvx.Warning("Dependency property not found for {0}", bindingDescription.TargetName); return; } var property = actualType.FindActualProperty(bindingDescription.TargetName); if (property == null) { Mvx.Warning("Property not returned {0} - may cause issues", bindingDescription.TargetName); } var sourceStep = bindingDescription.Source as MvxPathSourceStepDescription; if (sourceStep == null) { Mvx.Warning("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); return; } #if WINDOWS_PHONE || WINDOWS_WPF var newBinding = new System.Windows.Data.Binding #endif #if NETFX_CORE var newBinding = new Windows.UI.Xaml.Data.Binding #endif { Path = new PropertyPath(sourceStep.SourcePropertyPath), Mode = ConvertMode(bindingDescription.Mode, property?.PropertyType ?? typeof(object)), Converter = GetConverter(sourceStep.Converter), ConverterParameter = sourceStep.ConverterParameter, #if WINDOWS_PHONE FallbackValue = sourceStep.FallbackValue #endif }; BindingOperations.SetBinding(attachedObject, dependencyProperty, newBinding); }
protected virtual void ApplyBinding(MvxBindingDescription bindingDescription, Type actualType, FrameworkElement attachedObject) { DependencyProperty dependencyProperty = actualType.FindDependencyProperty(bindingDescription.TargetName); if (dependencyProperty == null) { Mvx.Warning("Dependency property not found for {0}", bindingDescription.TargetName); return; } var property = actualType.FindActualProperty(bindingDescription.TargetName); if (property == null) { Mvx.Warning("Property not returned {0} - may cause issues", bindingDescription.TargetName); } var sourceStep = bindingDescription.Source as MvxPathSourceStepDescription; if (sourceStep == null) { Mvx.Warning("Binding description for {0} is not a simple path - Windows Binding cannot cope with this", bindingDescription.TargetName); return; } #if WINDOWS_PHONE || WINDOWS_WPF var newBinding = new System.Windows.Data.Binding #endif #if NETFX_CORE var newBinding = new Windows.UI.Xaml.Data.Binding #endif { Path = new PropertyPath(sourceStep.SourcePropertyPath), Mode = ConvertMode(bindingDescription.Mode, property == null ? typeof(object) : property.PropertyType), Converter = GetConverter(sourceStep.Converter), ConverterParameter = sourceStep.ConverterParameter, #if WINDOWS_PHONE FallbackValue = sourceStep.FallbackValue #endif }; BindingOperations.SetBinding(attachedObject, dependencyProperty, newBinding); }