This is a migrated thread and some comments may be shown as answers.

RadMaskedTextBox in CellTemplate

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yonggu Kang
Top achievements
Rank 1
Iron
Yonggu Kang asked on 17 Sep 2012, 06:47 PM

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 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 18 Sep 2012, 06:03 AM
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.

0
Yonggu Kang
Top achievements
Rank 1
Iron
answered on 18 Sep 2012, 06:59 AM
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

Tags
GridView
Asked by
Yonggu Kang
Top achievements
Rank 1
Iron
Answers by
Dimitrina
Telerik team
Yonggu Kang
Top achievements
Rank 1
Iron
Share this question
or