Watermark text alignment

3 posts, 1 answers
  1. Vadimir
    Vadimir avatar
    24 posts
    Member since:
    Aug 2013

    Posted 29 Jan 2014 Link to this post

    Hi,

    I'm using the version Q3 2013 SP1 (2013.3.1204.40).
    Is it possible to make the watermark text, e.g. "Type a name" in the attached picture, right alignment?
    Thanks.

    Regards,
    Gong
  2. Answer
    Kalin
    Admin
    Kalin avatar
    1208 posts

    Posted 29 Jan 2014 Link to this post

    Hi Gong,

    You could easily achieve the desired by finding the WatermarkTextBox inside of the AutoCompleteBox and setting its HorizontalContentAlignment property to Right. You could do that when Loaded event of the AutoCompleteBox is fired, the handler should like as follows:

    private void auto_Loaded(object sender, RoutedEventArgs e)
    {
        var watermark = this.auto.ChildrenOfType<RadWatermarkTextBox>().First() as RadWatermarkTextBox;
        watermark.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Right;
    }

    However this will cause the text input when typing to also go on the right side, so what you can do is to set it back to Left on GotFocus event of the AutoComplete and set it back to Right on LostFocus. I have prepared and attached a sample project which demonstrates the exact approach.

    Hope this helps.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vadimir
    Vadimir avatar
    24 posts
    Member since:
    Aug 2013

    Posted 29 Jan 2014 in reply to Kalin Link to this post

    Hi Kalin,
    Thanks. This is exactly what I need.
    Regards,
    Gong
Back to Top