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

About IsReadonly

27 Answers 224 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
xiaofeng
Top achievements
Rank 1
xiaofeng asked on 13 Aug 2009, 03:24 AM
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!

27 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 13 Aug 2009, 01:31 PM
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.
0
xiaofeng
Top achievements
Rank 1
answered on 14 Aug 2009, 04:07 AM
Can you give me an example?Thank you !
0
Valeri Hristov
Telerik team
answered on 14 Aug 2009, 09:47 AM
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.
0
James
Top achievements
Rank 1
answered on 09 Sep 2009, 07:20 AM
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?
0
James
Top achievements
Rank 1
answered on 09 Sep 2009, 07:36 AM
Valeri,

sorry, pls ignore my last post, I found I can do it
0
Kevin White
Top achievements
Rank 2
answered on 07 Apr 2010, 03:14 PM
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.
0
James
Top achievements
Rank 1
answered on 07 Apr 2010, 04:27 PM
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
0
Kevin White
Top achievements
Rank 2
answered on 07 Apr 2010, 04:31 PM
Thanks
0
Anne Lyon
Top achievements
Rank 1
answered on 09 Jul 2010, 10:59 AM
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
0
James
Top achievements
Rank 1
answered on 09 Jul 2010, 01:55 PM
to set style at run-time, you can refer to this thread http://forums.silverlight.net/forums/p/13115/42714.aspx
0
Anne Lyon
Top achievements
Rank 1
answered on 12 Jul 2010, 11:05 AM
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?
0
Pana
Telerik team
answered on 13 Jul 2010, 12:05 PM
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
0
Kjell
Top achievements
Rank 1
answered on 24 Sep 2010, 11:56 PM
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? 
0
Pana
Telerik team
answered on 28 Sep 2010, 11:55 AM
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
0
Kjell
Top achievements
Rank 1
answered on 29 Sep 2010, 09:23 PM
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?
0
Pana
Telerik team
answered on 30 Sep 2010, 06:32 AM
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
0
Kjell
Top achievements
Rank 1
answered on 30 Sep 2010, 06:38 AM
Yep I meant black, sorry 'bout the typo.
0
Pana
Telerik team
answered on 04 Oct 2010, 09:13 AM
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
0
Kjell
Top achievements
Rank 1
answered on 04 Oct 2010, 08:45 PM
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?
0
Pana
Telerik team
answered on 05 Oct 2010, 06:39 AM
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
0
Kjell
Top achievements
Rank 1
answered on 05 Oct 2010, 04:45 PM
No problem but I think you did it again, there is no ComboBox.xaml in the new project.
0
Pana
Telerik team
answered on 06 Oct 2010, 07:02 AM
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
0
Kjell
Top achievements
Rank 1
answered on 07 Oct 2010, 06:13 PM
That worked perfectly, thank you.
0
Pana
Telerik team
answered on 08 Oct 2010, 06:34 AM
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
0
Murray
Top achievements
Rank 2
answered on 09 Jun 2014, 04:02 PM
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!
0
Murray
Top achievements
Rank 2
answered on 09 Jun 2014, 04:04 PM
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).
0
Yana
Telerik team
answered on 12 Jun 2014, 12:24 PM
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.
 
Tags
ComboBox
Asked by
xiaofeng
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
xiaofeng
Top achievements
Rank 1
James
Top achievements
Rank 1
Kevin White
Top achievements
Rank 2
Anne Lyon
Top achievements
Rank 1
Pana
Telerik team
Kjell
Top achievements
Rank 1
Murray
Top achievements
Rank 2
Yana
Telerik team
Share this question
or