1

I use the default WPF ribbon shipped with VS2012 Express.
When RibbonTextBox databound to double property in viewmodel initialised by value 1.75, it displays it and allows modifying numbers around the decimal separator without framing it in red colour as it does when entered non-numeric character such as 'x' etc.
But once decimal separator deleted, there's no way to type it back into the RibbonTextBox. It accepts nonsense characters, but not the decimal separator. In other words, after deleting the decimal separator, it behaves rather as databound to int.

XAML

xmlns:rib="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
...
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
<Label Content="Source Gamma " />
<rib:RibbonTextBox Text="{Binding SrcGamma, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="50"/>
</StackPanel>

C# code behind

public double SrcGamma { get; set; } // initialised to 1.75d

Note 1: First, I suspected it to be a culture problem. My Windows culture (cs-CZ) uses ',' decimal separator but my application displayed '.' separator.
a) Setting Windows culture separator to '.' didn't help.
b) After overrriding application locale according to this SO question, the correct Windows culture separator is displayed, but cannot be entered either.

Note 2: During my investigation I added a standard TextBox (outside the ribbon). After adding a custom double validation rule to it, it started behaving just the same way as the RibbonTextBox mentioned.

Thanks in advance for any suggestion.

Community
  • 1
  • 1
user681768917
  • 193
  • 1
  • 12

1 Answers1

0

The answer was hidden in this SO Article.

The strange behaviour was caused by UpdateSourceTrigger=PropertyChanged I used to use in .NET 3.5 where it behaved in an expected way. After removing it, the decimal separator can be added without any problems now.

Well, MS had reasons to do this change, so let's bear it in mind.

Community
  • 1
  • 1
user681768917
  • 193
  • 1
  • 12