About IsReadonly

28 posts, 0 answers
  1. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 12 Aug 2009 Link to this post

    The IsReadonly property does not work.I use IsEnabled,but the style is not good .The text is not clear when IsEnabled is false.What can I do for this?Does you have any solution which I can control the property by code?
    Thank you!
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 13 Aug 2009 Link to this post

    Hello xiaofeng,

    The read-only mode (IsReadOnly=true, IsEditable=true) of RadComboBox prevents the user from typing in the editable TextBox, but allows him to select items from the dropdown. To prevent the user from any selection you should set IsEnabled property to false, but as you mentioned, the style of the control is changed. To avoid the color change you could open the style of RadComboBox and change the color of the element with x:Name = DisabledVisual to whatever you like.

    Kind regards,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. xiaofeng
    xiaofeng avatar
    60 posts
    Member since:
    Jun 2008

    Posted 13 Aug 2009 Link to this post

    Can you give me an example?Thank you !
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 14 Aug 2009 Link to this post

    Hi xiaofeng,

    Please, check the following help topic for detailed steps that are needed to edit the Style of any Telerik control:
    http://www.telerik.com/help/silverlight/radcontrols-for-silverlight-expression-blend-support.html

    The other topics from the Styling and Appearance category might also be of help.

    Best wishes,
    Valeri Hristov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. James
    James avatar
    47 posts
    Member since:
    Jun 2009

    Posted 09 Sep 2009 Link to this post

    Valeri,
    The DisabledVisual is just a rectangle. how about I want to hide the combox border and the dropdown arrow in Disabled mode? We can do this on the silverlight TextBox control by customizing the style of its disabled state, but I don't know how to with RadComboBox. Any suggestion?
  7. James
    James avatar
    47 posts
    Member since:
    Jun 2009

    Posted 09 Sep 2009 Link to this post

    Valeri,

    sorry, pls ignore my last post, I found I can do it
  8. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 07 Apr 2010 Link to this post

    James, I am looking to do the same thing.  Can you post your code how you did this? I cant seem to get the dropdown arrow to hide.
  9. James
    James avatar
    47 posts
    Member since:
    Jun 2009

    Posted 07 Apr 2010 Link to this post

    Kevin,

    here is it Disabled visual state I did in the control template:

    <VisualState x:Name="Disabled">
                            <Storyboard Duration="0">
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="InnerBorder" Storyboard.TargetProperty="BorderThickness">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DropDownButton" Storyboard.TargetProperty="Visibility">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>

    James
  10. Kevin White
    Kevin White avatar
    60 posts
    Member since:
    Jun 2004

    Posted 07 Apr 2010 Link to this post

    Thanks
  11. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 09 Jul 2010 Link to this post

    Hello,
    I have a similar challenge: I want to disable my comboBox when the user is in "View" mode in the application, but I cannot have the style (back & foreColor and Border) that is default for disabled comboBox, and setting these properties in code has no effect. My problem is that I add the comboBox to a grid programmatically depending on what the user wants to select from the database.
    This means I cannot set the style at design time, I have to do it at run-time.
    I guess I can set some sort of style template in the XAML as the example here, but how do I assign this to a comboBox added at run-time?

    Thanks
  12. James
    James avatar
    47 posts
    Member since:
    Jun 2009

    Posted 09 Jul 2010 Link to this post

    to set style at run-time, you can refer to this thread http://forums.silverlight.net/forums/p/13115/42714.aspx
  13. Anne Lyon
    Anne Lyon avatar
    87 posts
    Member since:
    Jan 2010

    Posted 12 Jul 2010 Link to this post

    Thank you for this example. It works for setting the BorderBrush and BorderThickness for an enabled RadComboBox.
    But I cannot set the Background or Foreground, the colors just seem to be ignored. And if I set my RadComboBox to isEnabled = false, then I cannot set the BorderBrush either anymore, only thickness.
    Here is my code:
    in App.xaml: 

     

    <Style x:Key="DisabledCombo" TargetType="telerikInput:RadComboBox">
        <Setter Property="BorderBrush" Value="Red"/>
        <Setter Property="Background" Value="Yellow"/>
        <Setter Property="BorderThickness" Value="3"/>
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="IsEnabled" Value="False" />
    </Style>
    <Style x:Key="EnabledCombo" TargetType="telerikInput:RadComboBox">
        <Setter Property="BorderBrush" Value="Orange"/>
        <Setter Property="Background" Value="DarkBlue"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="White" />
        <Setter Property="IsEnabled" Value="True" />
    </Style>

     

     

     

    and in code:
     

     

    if (mode == Disabled)
         cmbBox.Style = (Style)Application.Current.Resources["DisabledCombo"]; 
    else 
         cmbBox.Style = (Style)Application.Current.Resources["EnabledCombo"];

     


    Only BorderThickness works in both cases, and BorderBrush only for enabled combo, background and foreground do nothing.

    What am I doing wrong?
  14. Pana
    Admin
    Pana avatar
    748 posts

    Posted 13 Jul 2010 Link to this post

    Hi Anne Lyon,

    RadComboBox has White background in editable mode and Gray LinearGradient when it is non editable. In WPF there are Style Triggers that can be used to change between 2 Brushes for background depending on that property but in Silverlight there are no triggers. We ended up specifying White as Background for the RadComboBox using it in its Editable template. If you want to change the colors the way you described Blend is the way to go. You can easily right-click Edit-a-Copy of the control template of the RadComboBox and adjust the colors you need (including MouseOver effects etc.)

    Best wishes,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 24 Sep 2010 Link to this post

    I am trying to do the same thing but all I really need is to just make the disabled text blank instead of grey, so it is a little easier to read.  I was able to do this by just editing the key "TextBlock_Foreground_Disabled":

     

    <SolidColorBrush x:Key="TextBlock_Foreground_Disabled" Color="#FF000000"/> <!-- default = 999999 (dark grey) -->


    The only problem is now when I apply this style, all the items in the list box have lines dividing them (when it is enabled obviously).  I don't want these lines and they are not there when I just use the built in style.  How do I get rid of them? 
  16. Pana
    Admin
    Pana avatar
    748 posts

    Posted 28 Sep 2010 Link to this post

    Hello Kjell,

    The ticket is up for version 2009.1 526 which is quite old about an year and a half. We had some theme changes. Now the disabled states are done through opacity animation so the content of disabled items is set an opacity of about 0.33 so that you can put UIElements like images in them and they still look fainted. Foreground however is hardly changed in Silverlight's VisualStateManager since the ContentPresenter has no Foreground property and changing the Foreground is a pain. Perhaps if you could send me your project with the exact dlls and xaml you are using for the combo I will be able  to fix the lines in Expression Blend.

    Sincerely yours,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 29 Sep 2010 Link to this post

    I am using Q2 2010 SP1.

    All I want to do is set the text color to blank when the combobox is disabled. I don't care if it's done with a style or in the code behind, can you creaet a sample project that does that?
  18. Pana
    Admin
    Pana avatar
    748 posts

    Posted 30 Sep 2010 Link to this post

    Hi Kjell,

    I am sorry. Do you mean 'black' (like #FF000000) instead of 'blank'? I will send you a style that keeps the foreground black in disabled states for the RadComboBox.

    Kind regards,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 30 Sep 2010 Link to this post

    Yep I meant black, sorry 'bout the typo.
  20. Pana
    Admin
    Pana avatar
    748 posts

    Posted 04 Oct 2010 Link to this post

    Hi Kjell,

    Here is the combobox style. Its text will be black when the combobox is disabled.

    All the best,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 04 Oct 2010 Link to this post

    Thanks for the response Panayot.  What should I be looking at in this project?  When I run it a blank page opens and I dont see anything in mainpage.xaml or ComboBoxStyle.xaml, what am I doing wrong?
  22. Pana
    Admin
    Pana avatar
    748 posts

    Posted 05 Oct 2010 Link to this post

    Hello Kjell,

    I am really sorry for that mistake. I have send wrong project. I am reattaching the right one. It should have ComboBox.xaml file that you can merge in your app.xaml and if you do not set theme or other styles on your combobox their disabled state will be like the combo in the attached project.

    Sincerely yours,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  23. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 05 Oct 2010 Link to this post

    No problem but I think you did it again, there is no ComboBox.xaml in the new project.
  24. Pana
    Admin
    Pana avatar
    748 posts

    Posted 06 Oct 2010 Link to this post

    Hello Kjell,

    I'll double check it this time.

    Sincerely yours,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  25. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 07 Oct 2010 Link to this post

    That worked perfectly, thank you.
  26. Pana
    Admin
    Pana avatar
    748 posts

    Posted 08 Oct 2010 Link to this post

    Hi Kjell,

    I am glad I could help and I am sorry for the wrong files. Thank you for your interest in our controls and If you have further questions do not hesitate to ask us.

    Best wishes,
    Panayot
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  27. Murray
    Murray avatar
    121 posts
    Member since:
    Aug 2010

    Posted 09 Jun 2014 Link to this post

    I'm sorry but this thread doesn't answer the original question. Why can a user change a selection when it is set to read only? Read only implies that it cannot be changed!
  28. Murray
    Murray avatar
    121 posts
    Member since:
    Aug 2010

    Posted 09 Jun 2014 Link to this post

    And before you mention isEnabled=false, I want the ability to select/copy text in an editable combo, but I don't want the user to be able to change the selected value (hence isreadOnly).
  29. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 12 Jun 2014 Link to this post

    Hello Murray,

    Setting IsReadOnly property only makes the TextBox in editable ComboBox readonly - it does not affect the selection as a whole.

    One possible way to achieve the desired approach is to edit the ControlTemplate of the ComboBox and to make the ToggleButton which opens the dropdown disabled. In this way, the user will not be able to select an item from the dropdown. I have attached a sample project demonstrated the approach, please note that I've used Implicit Styles as they make such customizations much easier.

    Download it and give it a try.

    Regards,
    Yana
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
DevCraft banner