Is there a simple way to change the Input box border color on focus and on mouse over without overwriting the entire style

2 posts, 0 answers
  1. sandeep
    sandeep avatar
    6 posts
    Member since:
    Jun 2014

    Posted 23 Sep 2014 Link to this post

    Is there a simple way to change the Input box border color on focus and on mouse over without overwriting the entire style.
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 25 Sep 2014 Link to this post

    Hi Sandeep,

    The easiest way to achieve the desired would be to get the borders named MouseOverVisual and FocusVisual from the Template of the control and set their BorderBrush colors. You can do that in the Loaded event handler of the DateTimePicker as shown below:

    private void DatePicker_Loaded(object sender, RoutedEventArgs e)
    {
        var picker = sender as RadDateTimePicker;
     
        var mouseOverBorder = picker.Template.FindName("MouseOverVisual", picker) as Border;
        mouseOverBorder.BorderBrush = Brushes.Red;
     
        var focusBorder = picker.Template.FindName("FocusVisual", picker) as Border;
        focusBorder.BorderBrush = Brushes.Red;
    }

    However this won't change the border around the drop down button - you would need to modify its Style in this case.

    Hope this help.

    Regards,
    Kalin
    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top