Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1015
Pass parameter to xamNumericEditor ValueConverter
posted

I have created a value converter that works fine for the xamNumericEditor. I need to send a parameter so that the converter does what I really need. I cannot use the standard Converter and ConverterParameter properties because I am not specifying fields as my xamDatagrid is bound to a dynamic DataTable object.

<Style TargetType="{x:Type igEditors:XamNumericEditor}">
                    <Setter Property="Mask" Value="{Binding ElementName=maskTextBox,Path=Text}"/>                    
                    <Setter Property="ValueToDisplayTextConverter" Value="{StaticResource ExConverter}"/>                    
                    <Setter Property="TrimFractionalZeros" Value="True"/>
                    <Setter Property="Foreground" Value="White" /> 
                    <Setter Property="ValueType" Value="{x:Type sys:Double}"/>
 </Style>
Parents
  • 30945
    Offline posted

    Hello Ed,

     

    Thank you for your post. I have been looking into the question that you are having and by default, the parameter of the ValueToTextConverter and the ValueToDisplayTextConverter, is the editor itself. What I can suggest is using the Tag property of the editor and use its value as parameter for the converter. Here is how you can implement this approach:

     

    XAML:

                <local:ExConverter x:Key="ExConverter"/>

                <Style TargetType="{x:Type igWPF:XamNumericEditor}">

                    <Setter Property="ValueToDisplayTextConverter" Value="{StaticResource ExConverter}"/>

                    <Setter Property="Tag" Value="hide"/>

                </Style>

     

    C#:

        public class ExConverter : IValueConverter

        {

            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

            {

                XamNumericEditor editor = parameter as XamNumericEditor;

                if (editor.Tag == "hide")

                {

                   // implement convertion based on parameter

                }

                if (value != null)

                    return value.ToString();

     

                return value;

            }

     

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

            {

                return value;

            }

        }

     

    Please let me know if you need any further assistance on the matter.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

Reply Children
No Data