05-03-2017 02:42 AM
Hi,
I'm trying to set the InteractionMode of a NumericTextBoxDouble to TextInput and ButtonClicks but I can't find the way to set 2 Mode like in xaml : InteractionMode="ButtonClicks TextInput"
How can I do this in c# ?
test1.InteractionMode = NumericTextBoxInteractionModes.TextInput;
Thanks
Solved! Go to Solution.
05-03-2017 10:04 AM
The format for flags enum values is to separate them with commas: InteractionMode="ButtonClicks, TextInput".
Also, if you edit the property in the Visual Studio designer, it should produce XAML with this format:
05-04-2017 02:31 AM
Thanks for the reply. I think you didn't understood my question. But I found an answer 🙂
XAML
<ni:NumericTextBoxInteractionModes x:Key="WithoutButton">ScrollWheel, ArrowKeys</ni:NumericTextBoxInteractionModes>
C#
ntbd.InteractionMode = (NumericTextBoxInteractionModes)this.FindResource("WithoutButton");
05-04-2017 10:05 AM
Ah, sorry for the misunderstanding: I thought you were trying to set it in XAML. In code, the syntax for combining flags enum values is to use the bitwise-OR operator:
ntbd.InteractionMode = NumericTextBoxInteractionModes.ScrollWheel | NumericTextBoxInteractionModes.ArrowKeys;
Retrieving a named XAML resource, as in your example, will also work fine.
05-04-2017 10:11 AM
Ahhh It is exactly what I was looking for !! Thanks 🙂