private void UpdateCameraSources() { List <TextBox> TextBoxes = new List <TextBox>(); TextBoxes.Add(Producer); TextBoxes.Add(Make); TextBoxes.Add(CameraNotes); BindingExpression bn; foreach (TextBox tb in TextBoxes) { bn = tb.GetBindingExpression(TextBox.TextProperty); bn.UpdateSource(); } DatePicker date = BoughtOn; bn = date.GetBindingExpression(DatePicker.SelectedDateProperty); bn.UpdateSource(); eisiWare.NumericUpDown iso = ISOLimitGood; bn = BindingOperations.GetBindingExpression(iso, eisiWare.NumericUpDown._value); bn.UpdateSource(); iso = ISOLimitAcceptable; bn = iso.GetBindingExpression(eisiWare.NumericUpDown._value); bn.UpdateSource(); }
private void UpdatePhotographerSources() { List <TextBox> TextBoxes = new List <TextBox>(); TextBoxes.Add(FirstName); TextBoxes.Add(LastName); TextBoxes.Add(PhotographerNotes); BindingExpression bn; foreach (TextBox tb in TextBoxes) { bn = tb.GetBindingExpression(TextBox.TextProperty); bn.UpdateSource(); } DatePicker date = Birthdate; bn = date.GetBindingExpression(DatePicker.SelectedDateProperty); bn.UpdateSource(); }
private void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e) { DatePicker cl = sender as DatePicker; cl.GetBindingExpression(DatePicker.SelectedDateProperty).UpdateSource(); }
private void CreateContent(object parentObject, FieldInformationAttribute fieldValues) { BindingMode bindingMode = this.PropertyInfo.CanRead && this.PropertyInfo.CanWrite ? BindingMode.TwoWay : this.PropertyInfo.CanWrite ? BindingMode.OneWayToSource : BindingMode.OneWay; Binding binding = new Binding(this.PropertyInfo.Name) { Path = new PropertyPath(this.PropertyInfo.Name), Source = parentObject, Mode = bindingMode, BindsDirectlyToSource = true, }; binding.ValidationRules.Add(new IsRequiredValidationRule { IsRequired = fieldValues.IsRequired, ObjectType = this.ObjectType }); this.IsTabStop = !fieldValues.IsReadOnly; switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: #region CHECK BOX CheckBoxItem check = new CheckBoxItem { IsEnabled = !fieldValues.IsReadOnly }; check.GotFocus += this.Item_Focuesd; this.DependencyProperty = CheckBoxItem.IsCheckedProperty; check.SetBinding(CheckBoxItem.IsCheckedProperty, binding); this.BindingExpression = check.GetBindingExpression(CheckBoxItem.IsCheckedProperty); this.contentObject = check; break; #endregion case ModelItemTypeEnum.ComboBox: case ModelItemTypeEnum.EnumBox: #region COMBO BOX ComboBoxTool comboBox = new ComboBoxTool { IsEnabled = !fieldValues.IsReadOnly, IsEditable = this.isComboBoxEdit }; comboBox.HorizontalAlignment = HorizontalAlignment.Stretch; comboBox.GotFocus += this.Item_Focuesd; this.LoadContentValues(parentObject, comboBox); this.DependencyProperty = this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty; comboBox.SetBinding(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty, binding); this.BindingExpression = comboBox.GetBindingExpression(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty); this.contentObject = comboBox; break; #endregion case ModelItemTypeEnum.DatePicker: #region DATE PICKER DatePicker date = new DatePicker { IsEnabled = !fieldValues.IsReadOnly }; //binding.ValidationRules.Clear(); date.HorizontalAlignment = HorizontalAlignment.Stretch; date.GotFocus += this.Item_Focuesd; this.DependencyProperty = DatePicker.SelectedDateProperty; date.SetBinding(DatePicker.SelectedDateProperty, binding); this.BindingExpression = date.GetBindingExpression(DatePicker.SelectedDateProperty); this.contentObject = date; break; #endregion case ModelItemTypeEnum.SecureString: #region SECURE STRING PasswordBoxBindable pass = new PasswordBoxBindable(parentObject) { IsEnabled = !fieldValues.IsReadOnly }; pass.HorizontalAlignment = HorizontalAlignment.Stretch; pass.HorizontalContentAlignment = HorizontalAlignment.Stretch; pass.LostFocus += this.Item_Focuesd; this.DependencyProperty = PasswordBoxBindable.PasswordTextProperty; pass.SetBinding(PasswordBoxBindable.PasswordTextProperty, binding); this.BindingExpression = pass.GetBindingExpression(PasswordBoxBindable.PasswordTextProperty); this.contentObject = pass; break; #endregion case ModelItemTypeEnum.ColorBox: case ModelItemTypeEnum.TextBox: default: #region TEXT BOX (DEFAULT) TextBoxItem text = new TextBoxItem { IsReadOnly = fieldValues.IsReadOnly, TextWrapping = TextWrapping.WrapWithOverflow }; text.MaxHeight = 250; text.MaxLength = fieldValues.MaxTextLength; text.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; text.HorizontalAlignment = HorizontalAlignment.Stretch; text.HorizontalContentAlignment = HorizontalAlignment.Stretch; text.SpellCheck.IsEnabled = this.isSpellCheck; text.LostFocus += this.Item_Focuesd; this.DependencyProperty = TextBoxItem.TextProperty; text.SetBinding(TextBoxItem.TextProperty, binding); this.BindingExpression = text.GetBindingExpression(TextBoxItem.TextProperty); this.contentObject = text; if (this.ObjectType == ModelItemTypeEnum.ColorBox && !text.Text.IsNullEmptyOrWhiteSpace()) { text.Background = ColourConverters.GetBrushfromHex(text.Text); text.Foreground = ColourConverters.InvertFromHex(text.Text); } break; #endregion } this.uxContent.Content = this.contentObject; }
private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { DatePicker dp = sender as DatePicker; dp.GetBindingExpression(DatePicker.SelectedDateFormatProperty).UpdateSource(); }