2 Answers, 1 is accepted
0

Peter
Top achievements
Rank 1
answered on 04 Feb 2010, 12:36 PM
I think I may have found the answer.
Create an Attached Property in a helper class:
public class EditableComboBox
{
public static int GetMaxLength(DependencyObject obj)
{
return (int)obj.GetValue(MaxLengthProperty);
}
public static void SetMaxLength(DependencyObject obj, int value)
{
obj.SetValue(MaxLengthProperty, value);
}
// Using a DependencyProperty as the backing store for MaxLength.
public static readonly DependencyProperty MaxLengthProperty =
DependencyProperty.RegisterAttached("MaxLength", typeof(int), typeof(EditableComboBox), new UIPropertyMetadata(OnMaxLengthChanged));
private static void OnMaxLengthChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var comboBox = obj as Telerik.Windows.Controls.RadComboBox;
if (comboBox == null)
{
return;
}
comboBox.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(DispatcherOperationCallback)delegate
{
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
if (textBox != null)
{
textBox.SetValue(TextBox.MaxLengthProperty, e.NewValue);
}
return null;
}
, null);
}
public static int GetCharacterCasing(DependencyObject obj)
{
return (int)obj.GetValue(CharacterCasingProperty);
}
public static void SetCharacterCasing(DependencyObject obj, int value)
{
obj.SetValue(CharacterCasingProperty, value);
}
// Using a DependencyProperty as the backing store for CharacterCasing.
public static readonly DependencyProperty CharacterCasingProperty =
DependencyProperty.RegisterAttached("CharacterCasing", typeof(int), typeof(EditableComboBox), new UIPropertyMetadata(OnCharacterCasingChanged));
private static void OnCharacterCasingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var comboBox = obj as Telerik.Windows.Controls.RadComboBox;
if (comboBox == null)
{
return;
}
comboBox.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(DispatcherOperationCallback)delegate
{
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
if (textBox != null)
{
textBox.SetValue(TextBox.CharacterCasingProperty, e.NewValue);
}
return null;
}
, null);
}
Then declare it in XAML:
<ti:RadComboBox IsEditable="True" local:EditableComboBox.MaxLength="20"/>
where 'local' is the location of the class in your code
Create an Attached Property in a helper class:
public class EditableComboBox
{
public static int GetMaxLength(DependencyObject obj)
{
return (int)obj.GetValue(MaxLengthProperty);
}
public static void SetMaxLength(DependencyObject obj, int value)
{
obj.SetValue(MaxLengthProperty, value);
}
// Using a DependencyProperty as the backing store for MaxLength.
public static readonly DependencyProperty MaxLengthProperty =
DependencyProperty.RegisterAttached("MaxLength", typeof(int), typeof(EditableComboBox), new UIPropertyMetadata(OnMaxLengthChanged));
private static void OnMaxLengthChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var comboBox = obj as Telerik.Windows.Controls.RadComboBox;
if (comboBox == null)
{
return;
}
comboBox.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(DispatcherOperationCallback)delegate
{
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
if (textBox != null)
{
textBox.SetValue(TextBox.MaxLengthProperty, e.NewValue);
}
return null;
}
, null);
}
public static int GetCharacterCasing(DependencyObject obj)
{
return (int)obj.GetValue(CharacterCasingProperty);
}
public static void SetCharacterCasing(DependencyObject obj, int value)
{
obj.SetValue(CharacterCasingProperty, value);
}
// Using a DependencyProperty as the backing store for CharacterCasing.
public static readonly DependencyProperty CharacterCasingProperty =
DependencyProperty.RegisterAttached("CharacterCasing", typeof(int), typeof(EditableComboBox), new UIPropertyMetadata(OnCharacterCasingChanged));
private static void OnCharacterCasingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
var comboBox = obj as Telerik.Windows.Controls.RadComboBox;
if (comboBox == null)
{
return;
}
comboBox.Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(DispatcherOperationCallback)delegate
{
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
if (textBox != null)
{
textBox.SetValue(TextBox.CharacterCasingProperty, e.NewValue);
}
return null;
}
, null);
}
Then declare it in XAML:
<ti:RadComboBox IsEditable="True" local:EditableComboBox.MaxLength="20"/>
where 'local' is the location of the class in your code
0
Hi Peter,
Thank you for contacting us.
We are glad that you have found a solution yourself. Your Telerik points have been updated.
If you need any further assistance concerning our controls please feel free to contact us again.
Greetings,
Konstantina
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Thank you for contacting us.
We are glad that you have found a solution yourself. Your Telerik points have been updated.
If you need any further assistance concerning our controls please feel free to contact us again.
Greetings,
Konstantina
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.