Posted 6 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

I would like to apply a watermark above ComboBoxes just like the TextBox control includes.  First, it would be great if that option was added to the control.  Since that's not availble today, I need to maually add it myself.  The following code is producing the desired results on my screen, however, I would like to apply the same style and margins generated by the Actipro TextBox control to display the watermark.

<TextBlock
	Classes="theme-form-control-label"
	Margin="0,8,2,2"
	Text="{x:Static lib:Resources.MISC_OPTIONS_THEME_LABEL}" />

<ComboBox
	Classes="theme-outline w400 mb-1"
	ItemsSource="{Binding AvailableThemeTypes}"
	SelectedItem="{Binding SelectedTheme}"
	SelectionChanged="Theme_SelectionChanged">
	<ComboBox.ItemTemplate>
		<DataTemplate>
			<TextBlock Text="{Binding Name}" />
		</DataTemplate>
	</ComboBox.ItemTemplate>
</ComboBox>

[Modified 6 months ago]

Comments (3)

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Michael,

Our themes for native Avalonia controls can only provide features like watermarks when the native controls have the related properties.  In this case, you would need to contact the Avalonia team (probably in their GitHub repo) about adding properties to ComboBox to support watermarks since there aren't any at the moment like there are for TextBox.

What you did above is correct for ComboBox, although our TextBox template doesn't explicitly set the Margin other than in the TextBlockFormControlLabel theme. 


Actipro Software Support

Posted 6 months ago by Michael Janulaitis - Corner Bowl Software
Avatar

Sorry I'm new to Avalonia, can you explain how I can find the settings in the TextBlockFormControlLabel theme?

Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Michael,

If you download the default styles/templates, look in the "Shared\Themes\Native\TextBlock.axaml" file for the definition.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.