timheuer / callisto

A control toolkit for Windows 8 XAML applications. Contains some UI controls to make it easier to create Windows UI style apps for the Windows Store in accordance with Windows UI guidelines.
http://timheuer.com/blog/archive/2012/05/31/introducing-callisto-a-xaml-toolkit-for-metro-apps.aspx
Other
338 stars 108 forks source link

NumericUpDown.Delay or NumericUpDown.Interval generates exceptions #236

Open zipswich opened 10 years ago

zipswich commented 10 years ago

No matter whether they are used in xaml or c# code, they always generates exceptions.

Environment: VS2012 on Windows 8.1

timheuer commented 10 years ago

I am not aware of this. How is it being used and what is the exception. The test app has no exceptions

zipswich commented 10 years ago

I came here per a suggestion from an MSFT forum moderator: http://social.msdn.microsoft.com/Forums/en-US/42d79a9c-43e0-4251-ae21-d4f32688eb43/how-to-use-callisto-numericupdowndelay-or-numericupdowninterval?forum=winappswithcsharp

timheuer commented 10 years ago

Are you setting properties correctly for minimum and maximum as well? Please provide the specific repro as the test app shows the values working fine.

zipswich commented 10 years ago

Thank you for your prompt response. I have to confess that I may not be using it correctly. I posted here per the encouragement of the moderator. Anyway, here is how to reproduce it. I started a brand new WS project as simple as possible. The following code ( I do not know what is the proper way to paste code here): <Page xmlns:Controls="using:Callisto.Controls" x:Class="Debug.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Debug" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Controls:NumericUpDown Maximum="255" HorizontalAlignment="Center" VerticalAlignment="Center" Value="255" />
</Grid>

The following code generates an exception. The only difference from the above code is Interval="200". Is this a misuse of this property?

<Page xmlns:Controls="using:Callisto.Controls" x:Class="Debug.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Debug" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <Controls:NumericUpDown Maximum="255" HorizontalAlignment="Center" VerticalAlignment="Center" Value="255" Interval="200" />
</Grid>

zipswich commented 10 years ago

It seems that the editor automatically remove the page tag of the code in my previous post.

timheuer commented 10 years ago

Ok, I understand the bug now. Let me explain. The Interval property is used for the delay for the plus/minus buttons when you hold them down. This is default set to 100 milliseconds which should be enough. The bug is that when setting the value the buttons aren't available yet. If you wanted to set this value, use a Loaded event handler on the control and set the value in the sender property which will be the control.

If what you really wanted was the Increment value, you can set that accordingly and the plus/minus will increment/decrement by that amount.

zipswich commented 10 years ago

Good. At least my understanding of Interval based on guessing is correct. I assume this applies to property Delay too. I am fine now. I originally wanted to speed it up.

I found another weir behavior. Please let me know if I should open another thread.

Let's use the code in my previous post as an example. Everything looks great until the number is deleted by the backspace key when the input box shrinks to little space. Afterwards, entering numbers will take effect, but the numbers cannot be seen because the input box seems to be able only to shrink, not grow.