I want to know that is there any way to apply CharacterSpacing to PlaceholderText in TextBox?
I tried to edit TextBox template and I noticed a ContentPresenter is showing PlaceholderText, I tried to use CharacterSpacing on it, but it did not work. Also, I tried FontStretch and again no result.
I tried to edit TextBox template and I noticed a ContentPresenter is showing PlaceholderText, I tried to use CharacterSpacing on it, but it did not work
The PlaceholderText is presented inside a ContentControl for the when use default style. And PlaseholderText is the value of content property. The type of content property is object, in the meanwhile, CharaterSpacing property is an attribute for string. So it seems like this is the reason why CharaterSpacing doesn't take effects. You will find controls with Text property such as TextBox,AutoSuggestBox and TextBlock can take effects on CharaterSpacing property since the type of Text property is string.
How to apply CharacterSpacing to PlaceholderText
If you want to apply CharaterSpacing to PlaceholderText here, you can use TextBox control instead of the ContentControl for PlaceholderTextContentPresenter to be a new style which will not influence the PlaceholderText feature. But you need to do some changes for appearence to let it seems same with before. Update code for the new TextBox style as follows:
<TextBox
x:Name="PlaceholderTextContentPresenter"
Grid.Row="1"
Grid.ColumnSpan="2"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Foreground="Gray"
CharacterSpacing="1000"
IsHitTestVisible="False"
BorderThickness="0"
Text="{TemplateBinding PlaceholderText}" />
And the result:
Related
For a xamarin forms project on my iPhone/iOS (12.4), I'm using ItemTemplate to showing ViewCells of a ListView.
This looks like this:
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
...
<Frame
BackgroundColor="{Binding Value, Mode=OneWay, Converter={StaticResource PositionToBackgroundColorConverter}}"
BorderColor="{Binding Value, Mode=OneWay, Converter={StaticResource PositionToTextColorConverter}, ConverterParameter={x:Static model:ItemComponent.Border}}">
...
This works pretty fine, sofar a selected item is not set. When I select an item, the selected row are drawing by the framework, and its background is set to gray. In this state the background of the frame is not drawn correctly. Or the background of the selection "overpainting" the background of the frame.
Do you know a (simple?) method to redraw the Frame, after the selected item is changed?
EDIT:
For example, to easier understanding the problem, I put here an image with two ViewCells. The first ListItem is not selected, the second ListItem is selected. This is a symbolic illustration of unwanted behavior!
When the ListItem is selected it should looks like this here:
Is there a possibility to use the Surface-keyboard to alter text in a normal textbox?
I'm creating a textbox and add the text in code behind. And now I want that the user can change the text if he touches the text.
<Grid x:Name="TextContainer" Margin="0,0,0,0" Background="Transparent" Height="66" Width="66">
<TextBlock x:Name="contentTextBlock" Margin="0" Text="NodeDesign_X" VerticalAlignment="Center" d:LayoutOverrides="Width" HorizontalAlignment="Center" Foreground="White" TextTrimming="CharacterEllipsis" TextWrapping="WrapWithOverflow" />
</Grid>
I didn't find possibilities to alter the SurfaceTextBox in the way my TextBlock locks now.
Thanks in advance!
Use a TextBox instead of TextBlock then the user can change the text. If you are in Surface Mode the Keyboard will be automatic popup if the TextBox gets the focus.
I define a label and set its value
<bbox>
<label id="notify" value="Test"/>
</bbox>
The width of the label is fix so if the value (text) is longer then the width
I want the line to break. I tried it with css doing
word-wrap:break word;
But this does not work. Is there a XUL element that provides such a feature or do you know an other technique?
You can do this with either the <label> or the <description> element, but you need to use its textContent rather than its value.
<label id="notify">Test</label>
I believe a xul description is what you want.
Why isnt this selected value binding working? I am utterly confused here. When I load the page, the first text box properly shows the contents of 'SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.NoteID', in this case '20'.
What SHOULD happen is when the page is first loaded, the combobox should have the note with ID 20 preselected.
However, the combobox and the second text box are both empty (but the list of notes is populated). As soon as I selected an entry, the 2nd combobox is updated with the newly selected Note ID.
This only happens when the page is first loaded. As soon as I select a different SelectedComponentAnalysisViewModel it all works fine and the appropriate value is automatically selected in the combobox.
My only guess here is that somehow the combobox is trying to bind to the selected value before it is populated. Is there some way to force it to wait till its populated to bind? Or at least make it try to bind after it has been populated? Or maybe the reverese is happening and its trying to load before its datasource is loaded? But if that were the case, then I would expect the first text box to be empty.
(the text boxes are just there to help me debug this)
<ComboBox x:Name="ReactionEffectNoteSelector" ItemTemplate="{DynamicResource DataTemplate1}" ItemsSource="{Binding NoteViewModelList}" SelectedValuePath="NoteID" SelectedValue="{Binding SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.NoteID, Mode=OneWay}">
<ComboBox.Resources>
<DataTemplate x:Key="DataTemplate1">
<TextBlock TextWrapping="Wrap" Text="{Binding NoteID, Mode=OneWay}"/>
</DataTemplate>
</ComboBox.Resources>
</ComboBox>
<TextBlock HorizontalAlignment="Right" Text="{Binding SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.NoteID}"/>
<TextBlock HorizontalAlignment="Right" Text="{Binding SelectedValue, ElementName=ReactionEffectNoteSelector, Mode=OneWay}"/>
Why are you binding the SelectedValue to SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.NoteID and then setting SelectedValuePath to NoteID? That implies that there is a SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.NoteID.NoteID property.
I think you want to set SelectedValue set to SelectedComponentAnalysisViewModel.ReacEffectViewModel.Note.
I have a usual TextBox. I know in order to change the color of some text I can use Run tag. But when I try to use it imperatively instead declaratively (because I need to do that dynamically) I have the text in TextBox like
AAA<Run...>Text to be changed in color</Run>
and sure nothing in color changes.
How can I change the color of some text in some program way?
Thanks
I'm fairly sure you have to use a RichTextBox for that, TextBox only works with plaintext.