Overwriting PromptBrush in DateTimeEditBox

Editors for WPF Forum

Posted 14 years ago by Andreas Dickau
Version: 10.1.0522
Avatar
Hi,

Is there a way to overwrite the default PromptBrush in DateTimeEdit controls (eg change the default dot to an underscore)?

Thanks
Andreas

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Andreas,

We don't have a setting exposed for the MaskedTextBox.PromptIndicatorType, but you can use a custom Style to set it. This should work:
xmlns:editors="http://schemas.actiprosoftware.com/winfx/xaml/editors"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"

<Style x:Key="{x:Static themes:EditorsCommonDictionary.MaskedTextBoxInlineStyleKey}" TargetType="editors:MaskedTextBox"
        BasedOn="{StaticResource {x:Static themes:EditorsCommonDictionary.MaskedTextBoxInlineStyleKey}}">
    <Setter Property="PromptIndicatorType" Value="Character" />
</Style>
You can set the PromptChar also, but it defaults to the underscorce character. You can also set the PromptBrush here, which is used to render the character or geometry.


Actipro Software Support

Posted 14 years ago by Andreas Dickau
Avatar
Thanks very much. That's exactly what I wanted.
Posted 14 years ago by Andreas Dickau
Avatar
Hi,

With the above style, how would I specify the mask to display 2 characters for the hours and minutes for time display? No matter what mask I specify, it always only prompts for one character for the hour part.
eg ##:## # for hours, minutes and AM/PM

Thanks
Andreas
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Andreas,

Only 1 prompt is display because currently the user can enter 1 or 2 digits (since 1-9 are all valid hours). The DateTimeHourPart has a Mask property that you could change to "\d{2}", but you'd have to explicitly change it (i.e. it can't be changed using an implicit Style). You could probably do this via an attached behavior, which uses an inherited attached property that looks for DateTimeHourPart/DateTimeMinutePart types.

The problem is the user would still be able to enter a single digit, as the parts just use the MaskedTextBox to ensure only valid digits are entered and doesn't verify the "length" of the text.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.