Tabindex not working for materialDesign:TimePicker - wpf

<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.

Related

What does controls:TextBoxHelper.IsWaitingForData do?

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

Checkbox in my windows 8.1 app won't activate in emulator

I know this is going to sound really stupid but is there anything I'm missing because I have a simple page in my windows 8.1 phone app with a checkbox and a button. I can click on the button just fine in the emulator but I can't get the checkbox to check or uncheck at all. I feel really stupid for not being able to do something this simple. Am I missing something here?
<Grid>
<TextBlock Name="lblTermsofAgreement"/>
<CheckBox Name="chkAcceptTerms" Checked="chkAcceptTerms_Checked" Click="chkAcceptTerms_Click" Unchecked="chkAcceptTerms_Unchecked" HorizontalAlignment="Center" Content="I accept the terms of agreement" VerticalAlignment="Center" IsEnabled="True"></CheckBox>
<TextBlock Name="lblTermsError" FontFamily="Red" Text="" />
<Button Name="btnAccept" Click="btnAccept_Click" Content="Accept" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Button>
</Grid>
All the controls are in row 0 column 0 for the grid so there was a control on top of it preventing it from getting checked. I would either add rows to the grid and set there rows or put the controls in a stack panel.
<Grid>
<StackPanel>
<TextBlock Name="lblTermsofAgreement"/>
<CheckBox Name="chkAcceptTerms" HorizontalAlignment="Center" Content="I accept the terms of agreement" VerticalAlignment="Center" IsEnabled="True"></CheckBox>
<TextBlock Name="lblTermsError" FontFamily="Red" Text="" />
<Button Name="btnAccept" Content="Accept" HorizontalAlignment="Center" VerticalAlignment="Bottom"></Button>
</StackPanel>
</Grid>

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 :)

WPF: Is there a sort of XAML tag that behaves like the HTML span element?

Coming from ASP.NET, this WPF stuff is just confusing. All I want to do is put a red asterisk by a label to indicate a required field. Playing around with stuff, I found that this actually does the trick:
<TextBlock Grid.Row="6" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top">
<Label Foreground="Red" Content="*" /><Label Content="Heavy Weight" />
</TextBlock>
Being that I just came up with this, I am not convinced it's the academic route a seasoned WPF developer would take. Additionally, this markup puts a huge amount of white space in between the asterisk and the label. In HTML, a span element would just render right beside its next sibling element. FYI, I tried putting a label within a label, but VS2010 kept barking about "The property 'content' is set more than once".
Any ideas?
Something like this would be more appropriate:
<TextBlock Grid.Row="6" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top">
<Span Foreground="Red">*</Span>Heavy Weight
</TextBlock>
Here is an overview of what can go into a TextBlock's content, more specifically here.
one more way is
<TextBlock Grid.Row="6" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top">
<Run Foreground="Red" Text="*" />
<Run Text="Heavy Weight" />
</TextBlock>
btw
Damascus's solution adds more UI Elements.
with CodeNaked's solution, its difficult to databind the Text.
The explanation is that you actually put two elements one after the other. You need to put them into a container.
Just a sample code of a sentence with red asterisk I did recently:
<StackPanel Orientation="Horizontal" Margin="5" >
<TextBlock Text="Display name"/>
<TextBlock Text="*" Foreground="Red" FontWeight="Bold" />
<TextBlock Text=":"/>
</StackPanel>
There, everything is in a StackPanel, so property 'content' will actually be set once (if you don't specify a group panel such as this one, you'll have to add only one element)

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