What does controls:TextBoxHelper.IsWaitingForData do? - wpf

I have a small WPF application that is using mahapp.metro for styling. There are 7 textboxes in the window with code similar to the examples below. When I run the application, it takes a lot of cpu, more than 90% if possible. When I deleted the controls:TextBoxHelper.IsWaitingForData="True", cpu usage dropped to almost 0% and I have not been able to find any issues. What does the TextBoxHelper.IsWaitingForData really mean?
<Canvas Grid.Column="0" Grid.Row="1">
<TextBox x:Name="SecurityStatusTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" IsReadOnly="True" Text="{Binding SelectedSecurityStatus, Mode=OneWay}"
Margin="50,50,0,0" Height="50" Width="250" FontSize="16"
controls:TextBoxHelper.ClearTextButton="True"
controls:TextBoxHelper.IsWaitingForData="True"
controls:TextBoxHelper.UseFloatingWatermark="True"
controls:TextBoxHelper.Watermark="{x:Static properties:Resources.SecurityStatus}"/>
<TextBox x:Name="BagTypeTextBox" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" IsReadOnly="True" Text="{Binding SelectedBagType, Mode=OneWay}"
Margin="325,50,0,0" Height="50" Width="250" FontSize="16"
controls:TextBoxHelper.ClearTextButton="True"
controls:TextBoxHelper.IsWaitingForData="True"
controls:TextBoxHelper.UseFloatingWatermark="True"
controls:TextBoxHelper.Watermark="{x:Static properties:Resources.BagType}"/>
</Canvas>

When the IsWaitingForData property is set to true an Effect is applied to the border of the TextBox and animation is applied to the Opacity property: https://github.com/MahApps/MahApps.Metro/blob/8a87a1b6ee7376e22930e465e8f3e85f4c5a73bc/src/MahApps.Metro/MahApps.Metro/Styles/Controls.TextBox.xaml
If you pay attention you will see that the TextBox gets a slight shadow that fades in and out when the IsWaitingForData property is set to true.
If this causes any issues for you should probably just set this property back to false.
You may also want to report the issue at GitHub: https://github.com/MahApps/MahApps.Metro/issues

Related

Tabindex not working for materialDesign:TimePicker

<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1">
<TextBlock Text="{x:Static meta:MetaCommon.Returned}" Style="{StaticResource SectionHeader}" Margin="0,0,0,10" />
<TextBlock Text="{x:Static meta:MetaCommon.Date}" Style="{StaticResource ContentHeader}" />
<DatePicker TabIndex="10" HorizontalAlignment="Left" MinWidth="200" Margin="0,0,0,10" />
<TextBlock Text="{x:Static meta:MetaCommon.Time}" Style="{StaticResource ContentHeader}" />
<materialDesign:TimePicker TabIndex="11" HorizontalAlignment="Left" Width="200" materialDesign:HintAssist.Hint="" Margin="0,0,0,0" />
</StackPanel>
So the TabIndex works properly for everything except TimePicker. It will just skip to the next TabIndex. I'd like it to tab to the TimePicker in the proper order.
I'm not sure what the issue is because I've tried various ways and it just doesn't follow the tab order I set. The only time it gets selected is if I keep "tabbing" through the controls it eventually gets selected.
I tried setting a TabIndex of both "0" and "1" and I tried setting TabStop to both "True" and "False" but nothing seems to work apart from continuous tabbing and hoping it gets selected.
I even tried setting it in the code behind to just to make sure.
As far as I can gather, it could be that, because it is a part of the Material Design XAML Toolkit, it doesn't support direct TabIndex like native controls.

Textbox Highlighting Always Starting at 0

This is really annoying.
I have basic textboxes which do not allow highlighting of single words/characters. Every time I try to select single words/characters, the highlight immediately jumps to the front of the box and highlights everything up to where I clicked.
<TextBox Name="txtTaskName" AutoWordSelection="False" Grid.Row="0" Grid.Column="2" Text="{Binding TaskName, Mode=TwoWay}" MaxWidth="300" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" TextWrapping="Wrap" VerticalContentAlignment="Center"></TextBox>
Suggestions?
Set AutoWordSelection="False" on your TextBox
<TextBox AutoWordSelection="False"/>

Calendar control width is too large at initialization of usercontrol

I have used calendar control and its display mode is year when my user control is loads then calender width s too large and doesn't appear when width is set .but when is select any month then width is set as it should
i m not getting what is the issue behind it
can anyone help me quickly???
Here is my code and what ever selected month will appear in textbox's text property and on click event of button my calendar control is set to visible
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="HorizontalHorizontalAlignment="Left "Margin="4">
<Label Content="Month: " HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="15" FontWeight="DemiBold" Margin="4"/>
<TextBox Height="23" HorizontalAlignment="Stretch" Name="SelectedMonthTextBox" VerticalAlignment="Top" Width="130" Margin="4" LostFocus="SelectedMonthTextBox_LostFocus" SelectionBrush="#FF767879"/>
<Button Content=".." Height="20" Width="20" Margin="4" Name="button" Click="button_Click" />
</StackPanel>
<Calendar Grid.Row="1" Grid.Column="0" Margin="50,-8" Panel.ZIndex="100" Name="calendar1" DisplayModeChanged="calendar1_DisplayModeChanged" DisplayDateChanged="calendar1_DisplayDateChanged" HorizontalAlignment="Left" DisplayMode="Year" Style="{StaticResource CalendarStyle}" Focusable="False" HorizontalContentAlignment="Left" VerticalAlignment="Top" />
i took a look your code and from information you provided so far, there is no any change a you describe. I believe that you should check following:
What happens in calendar1_DisplayModeChanged
How defined your style: StaticResource CalendarStyle
If it possible please post them here. I will try to help as soon as possible :)

Stop WPF TextBox from growing

I have spent two hours researching how to avoid that my WPF TextBox Control grows when a long text has been typed in, but I have not been able to do it, even I have read some answers about it like these ones:
stopping-wpf-textbox-from-growing-with-text
wpf-allow-textbox-to-be-resized-but-not-to-grow-on-user-input
wpf-how-to-stop-textbox-from-autosizing
My code is the following:
<Grid>
<TextBox Margin="6,6,8,28" Name="textBox1" AcceptsTab="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"/>
<CheckBox Content="Case sensitive" HorizontalAlignment="Left" Margin="7,0,0,2" Name="checkBox1" Height="16" VerticalAlignment="Bottom" />
</Grid>
One thing that I tried was:
MaxWidth={Binding ElementName=MyGrid, Path=ActualWidth}
But it did not work for me.
I also tried to add the following property to the Grid:
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Or
<Border x:Name="b" Grid.Column="1"/>
<TextBox Width="{Binding ActualWidth, ElementName=b}" ....... />
But it did not work either.
I need my control to grow when the user stretches the window, but not to when a long text is inserted.
Do you have a different answer for this problem that I might try?
UPDATE!
I have noticed something very strange: If I stretch manually the window, the textbox stops growing when a long text is inserted. That's fine. But I need to achieve this without having to stretch the window every time I run the program
Remove TextBox border and put it into ScrollViewer.
Try to do next:
<ScrollViewer MaxHeight={Binding ElementName=MyGrid, Path=ActualWidth} BorderThickness="0">
<TextBox Margin="6,6,8,28" Name="textBox1" AcceptsTab="True" TextWrapping="Wrap" AcceptsReturn="True"/>
</ScrollViewer>

Label Target="{Binding ElementName=UIName}" bug, or is it just me?

I've been tring to get this example to work, but there seems to be a bug in the code Label Target code, in that when you click on the second label the focus is set to the DatePicker rather than the TextBox, regardless which label you click first, also when you have entered the date the second label still sets it focus to DatePicker.
<!-- Unbound Date of Birth field -->
<sdk:Label Content="Date of Birth" IsRequired="True" Margin="5" />
<StackPanel Orientation="Horizontal" Grid.Column="1">
<sdk:DatePicker Height="23" />
<sdk:DescriptionViewer Description="Please enter your date of birth."/>
</StackPanel>
<!-- ID Number field -->
<sdk:Label Grid.Row="1" Margin="5" Target="{Binding ElementName=tbIdNumber}" />
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1">
<TextBox x:Name="tbIdNumber" Height="23" Width="100"
Text="{Binding IdNumber, Mode=TwoWay,
ValidatesOnExceptions=True, NotifyOnValidationError=True}" />
<sdk:DescriptionViewer Target="{Binding ElementName=tbIdNumber}"/>
</StackPanel>
I found this example here on the MSDN link text. To me this seems to be a bug, or am I just losing it?
Apologies if this is a duplicate question... I have googled this and all the examples seem to be the same, in that the target element is not being focused to.
It seems a reasonable assumption that clicking the label ought to move the focus to the associated control. However the Label does not actually provide that function.

Resources