private void SetIsEnabled(bool value) { object penultimateValue = GetPenultimateValue(); if (penultimateValue.IsNullOrUnsetValue()) { return; } IBindingMemberInfo member = BindingServiceProvider .MemberProvider .GetBindingMember(penultimateValue.GetType(), AttachedMemberConstants.Enabled, false, false); if (member == null) { Tracer.Warn("The member {0} cannot be obtained on type {1}", AttachedMemberConstants.Enabled, penultimateValue.GetType()); } else { member.SetSingleValue(penultimateValue, Empty.BooleanToObject(value)); if (_path.IsDebuggable) { DebugInfo($"Binding changed enabled state to '{value}' for source: '{penultimateValue}'"); } } }
private static object NullableBooleanToObject(bool?b) { if (b == null) { return(null); } return(Empty.BooleanToObject(b.Value)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) #endif { var b = (bool?)value; if (b == null) { return(null); } return(Empty.BooleanToObject(!b.Value)); }
private static void OnErrorsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { var newValue = (ICollection <object>)args.NewValue; sender.SetValue(HasErrorsProperty, Empty.BooleanToObject(newValue != null && newValue.Count != 0)); var errorsChanged = ErrorsChanged; if (errorsChanged != null) { errorsChanged(sender, newValue); } }
internal static void SetDisableHierarchyListener(this ViewGroup viewGroup, bool value) { if (!viewGroup.IsAlive()) { return; } var member = BindingServiceProvider.MemberProvider.GetBindingMember(viewGroup.GetType(), AttachedMembers.ViewGroup.DisableHierarchyListener, false, false); if (member != null && member.CanWrite) { member.SetSingleValue(viewGroup, Empty.BooleanToObject(value)); } }
private static void TrySetActivated(View view, bool value) { #if API17 view.Activated = value; #else if (view == null) { return; } var type = view.GetType(); var member = BindingServiceProvider.MemberProvider.GetBindingMember(type, "Activated", false, false); if (member != null && member.CanWrite) { member.SetValue(view, new[] { Empty.BooleanToObject(value) }); } #endif }
static PlatformExtensions() { SubscribeBackPressedEventDelegate = (o, action) => { try { var type = Type.GetType("Windows.Phone.UI.Input.HardwareButtons, Windows, ContentType=WindowsRuntime", false); if (type == null) { return; } var eventInfo = type.GetEventEx("BackPressed", MemberFlags.Public | MemberFlags.Static); var handleMethod = typeof(ReflectionExtensions.IWeakEventHandler <object>).GetMethodEx("Handle", MemberFlags.Public | MemberFlags.Instance); if (eventInfo == null || handleMethod == null || eventInfo.AddMethod == null) { return; } object token = null; var handler = ReflectionExtensions.CreateWeakEventHandler(o, action, (o1, h) => { if (token != null && eventInfo.RemoveMethod != null) { eventInfo.RemoveMethod.Invoke(null, new[] { token }); } }); var @delegate = handleMethod.CreateDelegate(eventInfo.EventHandlerType, handler); token = eventInfo.AddMethod.Invoke(null, new object[] { @delegate }); } catch (Exception e) { Tracer.Error(e.Flatten(false)); } }; SetBackPressedHandledDelegate = (o, b) => { if (BackArgsHandledProperty == null) { BackArgsHandledProperty = o.GetType().GetPropertyEx("Handled", MemberFlags.Public | MemberFlags.Instance); } if (BackArgsHandledProperty != null) { BackArgsHandledProperty.SetValue(o, Empty.BooleanToObject(b)); } }; }
private void SetIsEnabled(bool value) { object penultimateValue = GetPenultimateValue(); if (penultimateValue == null || penultimateValue.IsUnsetValue()) { return; } IBindingMemberInfo member = BindingServiceProvider .MemberProvider .GetBindingMember(penultimateValue.GetType(), AttachedMemberConstants.Enabled, false, false); if (member == null) { Tracer.Warn("The member {0} cannot be obtained on type {1}", AttachedMemberConstants.Enabled, penultimateValue.GetType()); } else { member.SetSingleValue(penultimateValue, Empty.BooleanToObject(value)); } }
internal static void SetBringToFront([NotNull] this Page page, bool value) { Should.NotBeNull(page, nameof(page)); ToolkitServiceProvider.AttachedValueProvider.SetValue(page, NavBringToFrontKey, Empty.BooleanToObject(value)); }
public void SetBoolProperty(string propertyName, string value) { SetStringProperty(propertyName, value, s => Empty.BooleanToObject(bool.Parse(s))); }