LookupElement combobox has a style that is not being overridden

4 posts, 0 answers
  1. Edmund Covington
    Edmund Covington avatar
    16 posts
    Member since:
    Jan 2014

    Posted 29 Jan Link to this post

    I am creating a GridViewComboBoxColumn programmatically and so am adding the CellTemplate programmatically with the code:

     

    private static DataTemplate GetCellTemplate(GridColumn column, DataTemplate itemTemplate, Binding itemsSourceBinding)
    {          
        FrameworkElementFactory lookupElement = new FrameworkElementFactory(typeof(LookupElement));
        if (itemsSourceBinding != null)
            lookupElement.SetBinding(LookupElementWithStyle.ItemsSourceProperty, itemsSourceBinding);
        lookupElement.SetValue(LookupElementWithStyle.ItemTemplateProperty, itemTemplate);
        lookupElement.SetValue(LookupElementWithStyle.SelectedValuePathProperty, column.MemberPath);
        lookupElement.SetBinding(LookupElementWithStyle.SelectedValueProperty, new Binding(column.DataName));
        lookupElement.SetValue(LookupElementWithStyle.IsTabStopProperty, false);
         
        DataTemplate cellTemplate = new DataTemplate()
        {
            VisualTree = lookupElement
        };
     
        cellTemplate.Seal();
        return cellTemplate;
    }

    The problem with this is that the LookupElement has a RadComboBox property that is displayed in the visual tree but I have no way of overriding the style. The result is that it is using the default FontFamily "Segoe UI SemiBold" when I want to use "Segoe UI", and any gridviewcomboboxcolumns are displayed as semibold. How do I overcome this?

     

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 01 Feb Link to this post

    Hi Edmund,

    The easiest way would be to create an implicit style targeting RadComboBox as follows:
    <Style TargetType="telerik:RadComboBox">
                <Setter Property="FontFamily" Value="Verdana" />
            </Style>

    Will that approach meet your requirements ? 

    Regards,
    Maya
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Edmund Covington
    Edmund Covington avatar
    16 posts
    Member since:
    Jan 2014

    Posted 01 Feb in reply to Maya Link to this post

    I already have an application wide Style for RadComboBox, but this doesn't affect the ComboBox that is a property of the LookupElement.
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Feb Link to this post

    Hi Edmund,

    I am sending the project I used for the test. Could you give it a try and let me know whether there is anything else that I need to do for reproducing the issue?

    Regards,
    Maya
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top