Exemplo n.º 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.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 = "%"
            });
        }
Exemplo n.º 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.SetBinding(DecimalPartGroup.IsReadOnlyProperty, new Binding("IsReadOnly")
            {
                Source = this
            });
            decimalGroup.SetBinding(DecimalPartGroup.MaximumProperty, new Binding("Maximum")
            {
                Source = this
            });
            decimalGroup.SetBinding(DecimalPartGroup.MinimumProperty, new Binding("Minimum")
            {
                Source = this
            });
            SyncBinding.CreateBinding(this, DecimalTextBox.ValueProperty, decimalGroup, DecimalPartGroup.ValueProperty);

            defaultItems.Add(decimalGroup);
        }