Example #1
0
        /// <summary>
        /// Generates a list of objects to be used in the DefaultItems collection.
        /// </summary>
        /// <param name="defaultItems">The collection that should be updated.</param>
        protected override void GenerateDefaultItems(SlottedItemCollection defaultItems)
        {
            base.GenerateDefaultItems(defaultItems);
            DecimalPartGroup decimalGroup = new DecimalPartGroup();

            decimalGroup.SetBinding(DecimalPartGroup.IsReadOnlyProperty, new Binding("IsReadOnly")
            {
                Source = this
            });
            decimalGroup.SetBinding(DecimalTextBox.StringFormatProperty, new Binding("StringFormat")
            {
                Source = this
            });
            decimalGroup.SetBinding(DecimalPartGroup.MaximumProperty, new Binding("Maximum")
            {
                Source = this, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalGroup.SetBinding(DecimalPartGroup.MinimumProperty, new Binding("Minimum")
            {
                Source = this, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            SyncBinding.CreateBinding(this, DecimalTextBox.ValueProperty, decimalGroup, DecimalPartGroup.ValueProperty, UpdateSourceTrigger.PropertyChanged);

            defaultItems.Add(decimalGroup);
        }
Example #2
0
        /// <summary>
        /// Generates a list of objects to be used in the DefaultItems collection.
        /// </summary>
        /// <param name="defaultItems">The collection that should be updated.</param>
        protected override void GenerateDefaultItems(SlottedItemCollection defaultItems)
        {
            base.GenerateDefaultItems(defaultItems);
            DecimalPartGroup decimalGroup = new DecimalPartGroup();

            decimalGroup.Style = this.TryFindResource("percentagePartGroup") as Style;
            decimalGroup.SetBinding(DecimalPartGroup.IsReadOnlyProperty, new Binding("IsReadOnly")
            {
                Source = this
            });
            decimalGroup.SetBinding(
                DecimalPartGroup.MaximumProperty,
                new Binding("Maximum")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalGroup.SetBinding(
                DecimalPartGroup.MinimumProperty,
                new Binding("Minimum")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalGroup.SetBinding(
                DecimalPartGroup.StepProperty,
                new Binding("Step")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalGroup.SetBinding(
                DecimalPartGroup.ValueProperty,
                new Binding("Value")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            SyncBinding.CreateBinding(
                this,
                PercentageTextBox.PartValueCommitTriggersProperty,
                decimalGroup,
                DecimalPartGroup.PartValueCommitTriggersProperty,
                UpdateSourceTrigger.Default);

            defaultItems.Add(decimalGroup);
            defaultItems.Add(new TextBlockPartGroup()
            {
                Text = "%"
            });
        }
        /// <summary>
        /// Generates a list of objects to be used in the DefaultItems collection.
        /// </summary>
        /// <param name="defaultItems">The collection that should be updated.</param>
        protected override void GenerateDefaultItems(SlottedItemCollection defaultItems)
        {
            // Allow the base class to provide most of the default items.
            base.GenerateDefaultItems(defaultItems);

            // This control will create a special group of parts for a decimal implementation of a percent value.
            DecimalPartGroup decimalPartGroup = new DecimalPartGroup();

            decimalPartGroup.SetBinding(DecimalPartGroup.StringFormatProperty, new Binding("Format")
            {
                Source = this
            });
            decimalPartGroup.SetBinding(DecimalPartGroup.IsReadOnlyProperty, new Binding("IsReadOnly")
            {
                Source = this
            });
            decimalPartGroup.SetBinding(
                DecimalPartGroup.MaximumProperty,
                new Binding("Maximum")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalPartGroup.SetBinding(
                DecimalPartGroup.MinimumProperty,
                new Binding("Minimum")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            decimalPartGroup.SetBinding(
                DecimalPartGroup.StepProperty,
                new Binding("Step")
            {
                Source = this, Converter = new PercentageConverter(), UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            SyncBinding.CreateBinding(
                this,
                DecimalTextBox.ValueProperty,
                decimalPartGroup,
                DecimalPartGroup.ValueProperty,
                UpdateSourceTrigger.PropertyChanged, new PercentageConverter());
            defaultItems.Add(decimalPartGroup);
            defaultItems.Add(new TextBlockPartGroup()
            {
                Text = "%"
            });
        }