Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
WPF custom control on texteditor
posted

Hi

In a windows text editor control ( Infragistics.Win.UltraWinEditors.UltraTextEditor ) we can override the onPaint event.  I use this to create a dotted line where the user may input their text

e.g.:

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)
        ' ==========================================================================================
        ' Draw a dotted line at the bottom of the control:
        ' ==========================================================================================
        Dim loPen As New Pen(SystemColors.ActiveCaption)
        loPen.DashStyle = Drawing2D.DashStyle.Dot
        e.Graphics.DrawLine(loPen, _
                            1, _
                            e.ClipRectangle.Height - 1, _
                            e.ClipRectangle.Width - 1, _
                  
End Sub
Is something like this possible in the XAMTextEditor?

  • 54937
    Verified Answer
    Offline posted

    In WPF controls do not normally handling rendering in code. Instead they are rendering by the composition of elements within the controls template. Therefore if you want to change the look of a control, you would create a new ControlTemplate for it and set that as its Template property. You can look at the DefaultStyles directory for xaml containing the styles/resources for the controls and use this as the basic for your custom template.