Skip to content

NumericUpDown Value not displayed #2515

@puchs

Description

@puchs

I know it sounds weird, but the NumericUpDown control will not show a value if:

1.) it is part of a DataTemplate
2.) and it contains a converter in a Binding of the Value property.
3.) and if either the Maximum or Minimum properties are set.

I have created a small sample solution, that exhibits the problem:

NumericUpDownTest.zip

The main window contains a ContentControl binding to the property "V" of the code-behind of the MainWindow class. It also contains a DataTemplate with two NumericUpDownControls. They are almost identical:

<NumericUpDown Grid.Row="0" Grid.Column="0" Height="23" Margin="5,5,5,5" Interval="1" StringFormat="{}{0:###0}" Value="{Binding Path=V, Converter={StaticResource identityConverter}, UpdateSourceTrigger=LostFocus}" />

The only difference is that one of the controls also contains the following two attributes (one is sufficient to trigger the problem):

Maximum="2000" Minimum="-273"

This control will not display the value bound to the NumericUpDown. The two attributes

diag:PresentationTraceSources.TraceLevel=High, Mode=TwoWay,

of the Binding do not change the situation and neither does the StringFormat attribute. The BindingExpression seems to "vanish" - at least that is what I see in the WPF debugger of Visual Studio 2015. I can also see (thanks to the Binding diagnostics) that the converter is called and returns a correct value.

How did I find the problem: I exchanged all occurences of the DoubleUpDown from the Extended WPF Toolkit in my application with the MahApps.Metro NumericUpDown. The problem appeared only after this exchange.

Expected outcome

Both NumericUpDownControls should display the same value.

Environment

  • MahApps.Metro 1.2.4, but I also could reproduce the problem with the development branch @ commit: 1c6480d
  • Windows 7 x64 all patches installed
  • Visual Studio 2015 Community
  • .NET Framework 4.5.2 (and also 4.6.1)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions