Foreground Combobox is not effect

6 posts, 0 answers
  1. Son
    Son avatar
    22 posts
    Member since:
    Jun 2011

    Posted 20 Sep 2011 Link to this post

    I have tried to set foreground to another color but it is always black. How can I set foreground ? Please help me
    <telerik:RadComboBox Foreground="Red" x:Name="PeriodComboBox" />
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 22 Sep 2011 Link to this post

    Hi Son,

    The Foreground property will work only in an editable RadComboBox. In order to change the color of the text in non editable RadComboBox you need to set SelectionBoxItemTemplate. You can check this example for more info.

    Greetings,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Son
    Son avatar
    22 posts
    Member since:
    Jun 2011

    Posted 23 Sep 2011 Link to this post

    <DataTemplate x:Key="ComboBoxSimpleTemplate">
        <Grid>
            <TextBlock Foreground="Red" Text="{Binding Name}" />
        </Grid>
    </DataTemplate>
    I tried to use SelectionBoxTemplate="{StaticResource ComboBoxSimpleTemplate}". it works fine but the problem is that I have many comboboxes with different itemsource like City, Country, Gender, Job, so on. ...
    If I use DataTemplate then I have to create one DataTemplate for each combobox. Because Text="{Binding Name}" depends on displayfield of that combobox.
    Ex. <TextBlock Foreground="Red" Text="{Binding City}" />
    <TextBlock Foreground="Red" Text="{Binding Gender}" />
    <TextBlock Foreground="Red" Text="{Binding JobName}" />
  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 29 Sep 2011 Link to this post

    Hi Son,

    You can achieve this by editing the template of the RadCombobox and then find NonEditable ComboBox and then set the Foreground of 
    <telerik:RadToggleButton x:Name="PART_DropDownButton" IsTabStop="False" Margin="0" Padding="0" ClickMode="Press" telerik:StyleManager.Theme="{StaticResource Theme}">

    Then apply the style to all RadComboBoxes and set the binding for each of them in its XAML. I have attached the template of RadComboBox for Office_Black theme. You can get the templates of other themes from your installation. The path is this:
    C:\Program Files (x86)\Telerik\RadControls for Silverlight Q2 2011 SP1\Themes

    Hope this works for you. Let me know if you need further help.

    All the best,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Son
    Son avatar
    22 posts
    Member since:
    Jun 2011

    Posted 29 Sep 2011 Link to this post

    Thank you Boyan
    Can you make it clear ? How can I edit the template of the RadCombobox and change the foreground in code behind ?
    Thanks
  7. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 03 Oct 2011 Link to this post

    Hello Son,

    This issue will be fixed with the internal build next week. You will be able to set the foreground of a non editable ComboBox through the Foreground property.
    Sorry for the caused inconvenience.

    Best wishes,
    Konstantina
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
DevCraft banner