Jump to content

Indirect UI – property rules


Recommended Posts


I don't want to abuse for your kindness but maybe you can help me in the next problem:

//two sliders AmountX, AmountY with link checkbox = AmountZ; if the checkbox is ticked then AmountX and AmountY sliders is linked.
propRules.Add(new LinkValuesBasedOnBooleanRule<int, Int32Property>(new ValueType[] { PropertyNames.AmountX, PropertyNames.AmountY }, PropertyNames.AmountZ, false)); //found on simonbrown site

//one slider = AmountX with enable checkbox = AmountY; if the checkbox is unticked then AmountX slider is disabled.
 propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.AmountX, PropertyNames.AmountY, true));//also found on simonbrown site

Now, if I have a dropdown list and I want to enable a slider when an option from that dropdown list is choosed, how can I make that?


propRules.Add(new ReadOnlyBoundToBooleanRule(PropertyNames.AmountXOptionN, PropertyNames.AmountY, true));//does not work


Edited by BoltBait
Split from unrelated topic
Link to comment
Share on other sites

Your code might look like this:

        protected override PropertyCollection OnCreatePropertyCollection()
            List<Property> props = new List<Property>();
            props.Add(StaticListChoiceProperty.CreateForEnum<AmountXOptions>(PropertyNames.AmountX, 0, false));
            props.Add(new Int32Property(PropertyNames.AmountY, 5, 0, 100));
            List<PropertyCollectionRule> propRules = new List<PropertyCollectionRule>();
            propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.AmountY, PropertyNames.AmountX, AmountXOptions.AmountXOptionN, true));
            return new PropertyCollection(props, propRules);

Pay attention to the last line.

  • Upvote 1
Link to comment
Share on other sites

  • 9 months later...

I believe the proper format is:

object[] conditions = new object[] { MyDropDownOptions.MyDropDownOption2, MyDropDownOptions.MyDropDownOption3 };

propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.MySlider, PropertyNames.MyDropDown, conditions, false));


EDIT: A more complete explanation is here.

  • Upvote 3
Link to comment
Share on other sites

Thank you MJW.
For more complex situations like the one in the picture below I tried to create a new cond2 condition, but it does not work.




object[] cond1 = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option5, Amount9Options.Amount9Option8};
            propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount10, PropertyNames.Amount9, cond1, true));
            propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount11, PropertyNames.Amount9, cond1, true));

object[] cond2 = new object[] {Amount9Options.Amount9Option3, Amount9Options.Amount9Option6};
            propRules.Add(new ReadOnlyBoundToValueRule<object, StaticListChoiceProperty>(PropertyNames.Amount10, PropertyNames.Amount9, cond2, true))


Edited by xod
Link to comment
Share on other sites

58 minutes ago, xod said:

For more complex situations like the one in the picture below I tried to create a new cond2 condition, but it does not work.


I'm not clear what each option is supposed to do. For instance, what the difference is between Option2 and Option5, both of which are labeled "Slider X, Y". it's certainly possible to enable any combination of the sliders with the list box.


Assuming the labels specify which controls to enable:

object[] condX = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option3, Amount9Options.Amount9Option5, Amount9Options.Amount9Option6, Amount9Options.Amount9Option8};

object[] condY = new object[] {Amount9Options.Amount9Option2, Amount9Options.Amount9Option4, Amount9Options.Amount9Option5, Amount9Options.Amount9Option7, Amount9Options.Amount9Option8};


You probably have something more complex in mind.

  • Upvote 1
Link to comment
Share on other sites

20 minutes ago, xod said:

It's about that kind of situation:


In that case, I expect the values I gave should work. Each control is independent: it only cares about the values that enable it, so there's really no additional complexity in enabling two slider controls with one list control.


If you were trying to enable a single control based on the values of two controls, that would be more complex -- and as far as I know, impossible.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...