Formatting not applied the first time the window is displayed

2 posts, 0 answers
  1. Tony
    Tony avatar
    111 posts
    Member since:
    May 2011

    Posted 17 Apr 2012 Link to this post

    My application is built in WPF.  I have a class called "MyWindow" that descends from the WPF Window class.  I have another class called "MyDialog" that also descends from the WPF Window class.  These two classes have a uniform look and functionality so it made sense to create my own base classes for the applicaiton.  The application is to be used on touch screen equipped laptops in police cars, so I've made everything bigger, to make it easier for people with large fingers to interact with the application.

    My application has a login dialog that descends from the MyDialog class.  During program startup, the application performs a number of steps, including loading a resource dictionary that contains brushes that are used to draw the application's controls.  Again, part of the whole unified look.

    The login dialog has a RadComboBox on it.  The app.xaml has a custom template for RadComboBoxes that increases the width of   the drop down button on the control.  The first time the login dialog is displayed, however, this template is not applied; the drop down button is the normal width.  However, if you enter a wrong password & click login, the dialog is redrawn and this time the drop down button is the right width.

    Why is the width of the RadComboBox wrong the first time but right the second time, even though every other aspect of the dialog is drawn right the first time?  I don't even know what code to include to help you guys help me on this.  Any ideas?

    Tony
  2. Dani
    Admin
    Dani avatar
    848 posts

    Posted 20 Apr 2012 Link to this post

    Hi Tony,

    I believe you custom style for RadComboBox does not get applied in the right time. If you render a RadComboBox and only then merge resources in your application resources, the RadComboBox will not pick up its style because it does not support dynamic theme switch. Instead, it will keep its default look. It will apply its new style only after the layout has been redrawn, i.e. refreshed. Which is why is picks up the style the second time. I suggest you try mergind resources on the application level before your layout in the dialog is rendered.

    Greetings,
    Dani
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top