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

Converter in radcombobox

1 Answer 131 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
gowthami
Top achievements
Rank 1
gowthami asked on 18 Aug 2011, 02:58 PM
Hai,

I have a combobox outside the grid.iam binding PhoneNumber In radcombobox.but i cannt binding in phoneformat.

How to display in phoneformat?
PhoneFormat.cs;
 public class PhoneFormat : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string PhoneNumber = null;
            if (value != null)
            {
                PhoneNumber = string.Format("{0:(###) ###-####}", System.Convert.ToInt64(value));
            }
            return PhoneNumber;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
 
        internal void Convert(int? nullable)
        {
            throw new NotImplementedException();
        }
 
 
xaml:
<UserControl x:Class="BusinessAccounting.View.CustomerCreditMemo.CustomerCreditMemo"
     xmlns:Converter="clr-namespace:BusinessAccounting.Helpers.Converters"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="1041"
             xmlns:telerikRibbonBar="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.RibbonBar"
             xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
             xmlns:TelerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"
             xmlns:TelerikCombo="http://schemas.telerik.com/2008/xaml/presentation"
 xmlns:Converter="clr-namespace:BusinessAccounting.Helpers.Converters"
 
 
 
<UserControl.Resources>
        <Icons:IconViewModel x:Key="iconviewmodel" />
        <!--<data:InvoiceContainer x:Key="Inv" />-->
        <Converter:PhoneFormat x:Key="phoneformat"/>
 
        <Style TargetType="GridViewFooter:GridViewFooterCell">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border BorderBrush="LightGray" BorderThickness="0,0,1,0" >
                            <Button x:Name="Btn_AddEmptyRow" Opacity="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Command="{Binding AddEmptyRowCommand, Source={StaticResource invoiceViewModel}}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
</UserControl.Resources>
 
 
<TextBlock x:Name="Lbl_Phone" Text="Phone" Grid.Row="0" Grid.Column="4" FontWeight="Normal" FontSize="10.667" VerticalAlignment="Top" Margin="5,0,0,0"/>
                        <telerikInput:RadComboBox x:Name="Cmb_Phone" 
                                  Grid.Row="0" Grid.Column="5" 
                                  Height="19" VerticalAlignment="Top"
                                   
                                  IsEditable="True" IsTextSearchEnabled="True"
                                  SelectedValuePath="PhoneID" Style="{StaticResource RadComboBoxStyle}"
                                  telerik:TextSearch.TextPath="PhoneNumber"
                                  FontSize="10.667" MinHeight="15" TabIndex="8" SelectionChanged="Cmb_Phone_SelectionChanged"  
                                                  ItemsSource="{Binding Phone}"   ClearSelectionButtonVisibility="Visible" SelectedItem="{Binding SelectedPhone,Converter={StaticResource phoneformat}, ConverterParameter={StaticResource Phoneformat}}"
                                  SelectedValue="{Binding CurrentInvoice.PhoneID}" >
 
                           
                            <TelerikCombo:RadComboBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <VirtualizingStackPanel />
                                </ItemsPanelTemplate>
                            </TelerikCombo:RadComboBox.ItemsPanel>
 
                        </telerikInput:RadComboBox>
                        <Border x:Name="Bdr_Phone" Grid.Row="0" Grid.Column="4" Grid.ColumnSpan="2" BorderThickness="1" VerticalAlignment="Top" Height="19"/>

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 22 Aug 2011, 03:19 PM
Hello Gowthami,

Your requirement is not supported in RadComboBox when the IsEditable property is set to true.You need to create a property in your data items that returns the formatted value.

Greetings,
Valeri Hristov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
ComboBox
Asked by
gowthami
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or