Hi,Could you please provide the solution for below issue:
My Purpose :I have one "Double" field bounded to WPF XamDataGrid,and I Need to show the Parenthesis for negative values
Example -123,005 to be shown as (123,005)
My Approach:I have applied ControlTemplate and Converter to achieve my purpose
Issue : I was NOT able to EDIT this double field after applying the "Control Template" and "Converter"
Thanks,
Hi Alex,
Could you please find refer my sample code and tell where i need to apply XamTextEditor.ValueToDisplayTextConverter ?
XAML
<Grid Name="gridPanel"> <Grid.Resources>
<Style x:Key="DoNotUseCommaUseParenthesisStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content,Converter={StaticResource parenthesisForNegativeAndNoCommaConvert}}"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
Code behind:
stdGrid.FieldLayouts[0].Fields["MyBalanceDoubleField"].Settings.CellValuePresenterStyle = (Style)gridPanel.Resources[DoNotUseCommaUseParenthesisStyle];
Converter Class
public class ParenthesisForMinusAndNoCommaConverter:IValueConverter { #region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double doubleValue=(double)value; if (doubleValue < 0) { string absoluteStrVal = Math.Abs(doubleValue).ToString(); return string.Format("({0})", absoluteStrVal); } return doubleValue; }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }
#endregion }
Hello,
What you can do is to set the ValueToDisplayTextConverter property to a IValueConverter object and use it to wrap the displayed text in paranthesis.
Let me know if you have questions on this.