-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Samples] ToolkitSampleMultiChoiceOption
should take a converter method parameter/Action
#149
Comments
Another pitfall I just encountered. @Arlodotexe we should have a generator analysis to make sure you don't pick a name for a common XAML enum like E.g. I need to do this: [ToolkitSampleMultiChoiceOption("LayoutOrientation", title: "Orientation", "Horizontal", "Vertical")] And not this: [ToolkitSampleMultiChoiceOption("Orientation", title: "Orientation", "Horizontal", "Vertical")] As this'll cause a cryptic error:
Took me a minute to realize |
Realized we probably need to use |
Was thinking, we could just accept an |
Curious if we could use the |
Problem Statement
@Arlodotexe I was just creating a sample for Expander and was using
ToolkitSampleMultiChoiceOption
for the expand direction of 'Down' or 'Up':Labs-Windows/labs/Expander/samples/Expander.Sample/ExpanderFirstSamplePage.xaml.cs
Line 31 in 3b9d3c6
However, these are strings... so I needed to add a long unwieldy converter that most folks wouldn't need to the sample:
Labs-Windows/labs/Expander/samples/Expander.Sample/ExpanderFirstSamplePage.xaml
Line 11 in 3b9d3c6
Labs-Windows/labs/Expander/samples/Expander.Sample/ExpanderFirstSamplePage.xaml.cs
Lines 40 to 45 in 3b9d3c6
Suggested Solution
It'd be nice if instead, we could have this be part of the Labs sample source generation process here to simplify they desired output for these scenarios:
As in an app scenario, the developer is probably just using the enum type directly, this is a sample implementation detail in the current setup.
Ideally, we could specify the method/action for converting in the attribute (as an
Action
I guess or delegate, that should mean llambda or method are supported I think):(I'm not sure how the current implementation works, so this may require two properties linked together, one bound to the generated UI that uses the string/radio connection, and another one which listens to that, passes through the function, and is the one bound by the sample.)
But the idea is, this would generate the
ExpandDirection
with the return type of the converter function instead ofstring
and then when the user selects the option and updates the value would pass it through the action specified first.Also, if a method is tagged in the attribute this way, we should hide it in the C# code view for displaying the sample code.
Other Considerations
Or maybe we want it to be based off a
bool
for the sample:In this case the sample class would actually have two converters, one that converts our string to the bool being expected by the sample for
IsExpanderDown
, and then the one the sample is actually using to demonstrate mapping that to an enum.Other Notes
The Sample Author may want to just show a converter, and that should be fine. This is more for cases with enums or other complex types where you want a simple selection choice and a simple binding (as would appear in an app).
The text was updated successfully, but these errors were encountered: