Problem with inheriting from ValueCOmmandParameter

Ribbon for WPF Forum

Posted 8 years ago by Robert Croshere
Version: 11.1.0543
Avatar
Hi,

I would like to add some additional properties to a gallery command parameter and decided to create an implementation of DoubleValueCommandParameter which inherites from the actipro commandparameter class.

My ribbon is configured like this:

<UserControl.Resources>
<ResourceDictionary>
<x:Array
x:Key="borderWidths"
Type="{x:Type sys:Double}">
<sys:Double>1</sys:Double>
<sys:Double>1.5</sys:Double>
<sys:Double>2</sys:Double>
<sys:Double>2.5</sys:Double>
</x:Array>
</ResourceDictionary>
</UserControl.Resources>

<ribbon:PopupGallery
ItemsSource="{Binding Source={StaticResource borderWidths}}">
<ribbon:PopupGallery.CommandParameter>
<self:DoubleValueCommandParameter />
</ribbon:PopupGallery.CommandParameter>
</ribbon:PopupGallery>


public class DoubleValueCommandParameter : actipro.DoubleValueCommandParameter { }

Without this implementation, I receive the ValueCommandParameter<double>, so in theory the DoubleValueCommandParameter should be fine, as this approach works for me when used with a Brush instead of a double in other parts of the ribbon.

However when I run the code I receive a NullReferenceException with only the following line as stacktrace:

at ActiproSoftware.Windows.Controls.Ribbon.Input.ValueCommandParameter`1.ActiproSoftware.Windows.Controls.Ribbon.Input.IValueCommandParameter.set_Value(Object value)

When I change the DoubleValueCommandParameter to ObjectValueCommandParameter (again own implementation with additional properties), the code runs just fine.
However, I need the CommandParameter to be “typed” correctly, and a double should be passed as value.

Any ideas of how to get this working?

Robert Croshere

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Robert,

It's hard to say without having a sample to debug. Please make a new simple sample project that shows the issue and email it to our support. Rename the .zip file extension so it doesn't get spam blocked and reference this forum post in your message with steps to dupe it. Thanks!


Actipro Software Support

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Robert,

Thanks for the sample.

A null value was trying to be assigned. If you change your DobuleValueCommandParameter to inherit actipro.ValueCommandParameter<Double?> instead (note the nullable double), it works fine.


Actipro Software Support

Posted 8 years ago by Robert Croshere
Avatar
Boy, I should of thought of that myself...
Thanks!

Robert.
The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.