RadMaskedTextBox in CellTemplate

3 posts, 0 answers
  1. Yong Gu Kang
    Yong Gu Kang avatar
    103 posts
    Member since:
    Jan 2010

    Posted 17 Sep 2012 Link to this post

    Hi telerik,

    I'm trying to bind numeric decimal point dynamically in GridViewCell,
    and tried to use GridViewMaskedTextBoxColumn,however, Mask property is not
    bindable as addressed in many threads here.

    So, I added RadMaskedTextBox as cell DataTemplate and binded his Mask into my ViewModel's
    property. So far so good except one thing.

    Every cell shows 2 border,one is gridView cell's border and the other is RadMaskedTextBox's border.
    Though I tried to set RadMaskedTextBox's  Border as transparent and 0 thickness,it's useless.

    How can I show that cell same look and feel with normal gridview cell when it is readonly state ?
    Follwoing is my XAML snippet.  Thank you in advance.

    Kang

    <telerik:GridViewDataColumn.CellTemplate>
                                            <DataTemplate>
                                                <telerik:RadMaskedTextBox Value="{Binding Path=CustQty}" Style="{StaticResource QtyMaskStyle}" Mask="{Binding Path=QtyFormat, Source={StaticResource stockSearchViewModelViewSource}}" />
                                            </DataTemplate>
                                        </telerik:GridViewDataColumn.CellTemplate>
     
    <Style x:Key="QtyMaskStyle" TargetType="telerik:RadMaskedTextBox">
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="FontSize" Value="{StaticResource NormalFontSize}"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="MaskType" Value="Numeric"/>
            <Setter Property="IsSpinEnabled" Value="False"/>
        </Style>
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 18 Sep 2012 Link to this post

    Hello Kang,

     You can define a CellEditTemplate instead. That way the look of the cell in View mode will be the original one and you will have the RadMaskedTextBox in Edit mode. Does this work for you?

    Regards,
    Didie
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. Yong Gu Kang
    Yong Gu Kang avatar
    103 posts
    Member since:
    Jan 2010

    Posted 18 Sep 2012 Link to this post

    Hi, Didie,

    Thank you for your kind info.
    Why didn't I notice that when I tried with celledit template before ?  How foolish I am.
    I spend nearly 1 day to implement dynamic decimal point with various way,
    finally done with IValueConvertor with dependancy property which binds deicmal format,
    however that can't be applied in row by row.
    Now i can have 2 options in dynamic decimal point.
     Thank you again.

    RGDS
    kang

Back to Top