How do I set a style for a ReadOnly ComboBox

5 posts, 1 answers
  1. Henrik Skak Pedersen
    Henrik Skak Pedersen avatar
    16 posts
    Member since:
    Nov 2006

    Posted 29 Nov 2012 Link to this post

    Hi,

    How do I set a style for a ReadOnly ComboBox? On a textbox you have a visual state called ReadOnly and you can set it like this:

    <VisualState x:Name="ReadOnly">
    .....
    </VisualState>

    I would like to set this both for the NonEditableComboBox and the EditableComboBox.

    How can I accomplish this?

    Thanks
    Henrik Skak Pedersen 
  2. Masha
    Admin
    Masha avatar
    355 posts

    Posted 04 Dec 2012 Link to this post

    Hello Henrik,

    Setting the RadComboBox's IsReadOnly property to True will affect the RadComboBox only when it is editable and there is no visual element for it. It serves to  keep the editable look, but will prevent the user from typing. Did you mean you need to style the Disable look of RadComboBox? If it is what you want, you should modify  inside Editable and NonEditable control template of RadComboBox and particular inside VisualState x:Name="Disabled".

    Let me know if it works for you.

    Regards,
    Maria
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Henrik Skak Pedersen
    Henrik Skak Pedersen avatar
    16 posts
    Member since:
    Nov 2006

    Posted 05 Dec 2012 Link to this post

    Hello Maria,

    Thank you for your reply. I know about the styling of the disabled box. But I would like to do this:
    <VisualState x:Name="ReadOnly">

    Just like the standard Silverlight TextBox.

    Thanks
    Henrik
  5. Answer
    Masha
    Admin
    Masha avatar
    355 posts

    Posted 05 Dec 2012 Link to this post

    Hello Henrik,

    The easiest way to create a VisualState for IsReadOnly propert is to create a custom class which inherits RadComboBox and call ChangeVisualState when IsReadOnly property is set. I've created a sample project to demonstrate the approach. You could find it attached.

    Hope it helps.

    All the best,
    Maria
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Henrik Skak Pedersen
    Henrik Skak Pedersen avatar
    16 posts
    Member since:
    Nov 2006

    Posted 06 Dec 2012 Link to this post

    Perfect, thank you :-)
Back to Top
DevCraft banner