xceed IntegerUpdown's TabIndex has no effect - wpf

I have 4 IntegerUpDowns from the Xceed toolkit. The problem is that the navigation through Tab button does not work at all. I set TabIndex, TabStop properties, but no effect. Maybe somebody had this problem? Any help will be appreciate! Thanks a lot!
Here is a code:
<GroupBox Margin="20"
HorizontalAlignment="Center"
Header="groupbox header text">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Margin="7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text1:" />
<xctk:IntegerUpDown Name="updown1"
Width="50"
Height="25"
Margin="17,0,30,0"
TabIndex="0"
IsTabStop="True"
VerticalAlignment="Center"
Increment="1"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown1_OnValueChanged"
Value="{Binding Property1,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text2" />
<xctk:IntegerUpDown Name="updown2"
Width="50"
Height="25"
Margin="43,0,0,0"
VerticalAlignment="Center"
Increment="2"
TabIndex="2"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property2,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Row="1"
Margin="7,0,7,7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text3:" />
<xctk:IntegerUpDown Name="updown3"
Width="50"
Height="25"
Margin="7,0,30,0"
VerticalAlignment="Center"
Increment="1"
TabIndex="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown3_OnValueChanged"
Value="{Binding Proeprty3,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text4:"/>
<xctk:IntegerUpDown Name="updown4"
Width="50"
Height="25"
Margin="7,0,0,0"
TabIndex="3"
VerticalAlignment="Center"
Increment="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property4,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</GroupBox>

Related

Changing image width inside datatemplate dynamically with a slidercontrol

I have populated a Listview with Images and I want to change the size of the Images dynamically with a slider. I couldnt find any solution yet. How can I do that?
<ListView ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Width="{Binding ElementName=Windowdefault, Path=ActualWidth}" Margin="5" MouseDoubleClick="TvBox_MouseDoubleClick" x:Name="TvBox" VerticalAlignment="Top">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Wrapalign:AlignableWrapPanel HorizontalContentAlignment="Center" HorizontalAlignment="Center" ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="stack" Margin="0 0 0 0" Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<StackPanel Margin="-25 -8 -25 -5">
<Image Width="100" x:Name="ImagesGrid" Source="{Binding ID,Converter={StaticResource ImagePathConverter}}" HorizontalAlignment="Stretch" VerticalAlignment="Top" Stretch="UniformToFill" />
<TextBlock x:Name="ID" HorizontalAlignment="Center" FontWeight="Light" Text="{Binding ID}" VerticalAlignment="Bottom" />
</StackPanel>
<TextBlock Visibility="Collapsed" x:Name="Flname" MaxWidth="60" TextAlignment="Center" FontSize="7" TextWrapping="Wrap" HorizontalAlignment="Center" FontWeight="Light" Text="{Binding Name}" VerticalAlignment="Bottom" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
This is pretty simple to accomplish.
Using your code as a starting point, I added a Slider with the x:Name="Slider". In the DataTemplate I setup a binding on the Image to be the Value of the Slider.
The Slider has a Minimum="100" and Maximum="1000" for the example.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Slider x:Name="Slider"
Grid.Row="0"
Interval="1"
Maximum="1000"
Minimum="100"
Value="100" />
<ListView
Grid.Row="1"
Margin="5"
VerticalAlignment="Top"
ItemsSource="{Binding Images}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Orientation="Vertical">
<StackPanel>
<Image x:Name="ImagesGrid"
Width="{Binding ElementName=Slider, Path=Value}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Source="{Binding Image}"
Stretch="UniformToFill" />
<TextBlock x:Name="ID"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontWeight="Light"
Text="{Binding Name}" />
</StackPanel>
<TextBlock
MaxWidth="60"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="7"
FontWeight="Light"
Text="{Binding FileName}"
TextAlignment="Center"
TextWrapping="Wrap"
Visibility="Collapsed" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
I hope this helps!

Adding Scrollbar to ItemsControl

I have a long list coming from my Business logic which I need to display on the UI. As the list is long, I tried adding Scrollviewer but I am unable to scroll.
please find the XAML code below
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>
Put it into a ScrollViewer.
<ScrollViewer>
<StackPanel >
</StackPanel>
</ScrollViewer>
As #StepUp points out you can just wrap it with a ScrollViewer but I believe this breaks virtualization. That's outside the scope of this question of course but it's something to keep in mind. If performance is likely to become an issue then I'd suggest implementing this as shown in the answer to this question.
The scrollviewer needed a Height to be set
<Grid Margin="0,32,0,0">
<TextBlock Text="{Binding IDC_WiFi, Source={StaticResource Resources}}" FontFamily="Segoe UI" FontSize="20" Foreground="#4cb5ab" HorizontalAlignment="Left" />
<Button Command="{Binding HardwareWifiAccordionCommand}" BorderThickness="0" Width="16" HorizontalAlignment="Right" Height="16" >
<Button.Background>
<ImageBrush ImageSource="{Binding AccordionImageHardwareWifi}" />
</Button.Background>
</Button>
</Grid>
<TextBlock Text="Klein's, Anil's" FontFamily="Segoe UI" FontSize="15" Foreground="#8fa3ad"/>
<StackPanel Height="200" Visibility="{Binding IsAccordionHardwareWifi, Converter={StaticResource Bool2Visible}}">
<ScrollViewer VerticalScrollBarVisibility="Auto" Height="350">
<ItemsControl ItemsSource="{Binding WifiList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,32,0,0">
<Grid>
<Image Source="/Images/Assets/da_wifi1_16x16.png" Height="16" Width="16" HorizontalAlignment="Left" />
<TextBlock Margin="25,0,0,0" Text="{Binding NetworkName}" FontSize="15" Foreground="#FFFFFF" />
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Right" />
</Grid>
<TextBlock Text="" FontSize="15" Foreground="#8fa3ad" HorizontalAlignment="Left" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</StackPanel>

Pop up is not opening after Rebinding the DataGrid

I have started to work on WPF recently. Currently I am facing an issue.
I have a window , inside that i have an user control which Contains DataGrid, Combobox ,Buttons and a Pop Up.
I am binding DataGrid with List of Notes(string) with Delete Buttons.So when we click on that Button, the pop up will open and Pop up has confirmation message with Yes or No button.
When i click the Yes button i am deleting the Note and Rebinding only the DataGrid.And after that when i click on the Delete Button the pop up is not opening.
If I dont Rebind the DataGrid, in that case PopUp is opening but the problem is deleted Note is still there in the DataGrid though that is deleted from the database, which make confusion whether the Note is deleted or not. That is why I am rebinding.
But Rebinding cause the issue of not opening Popup.
Please help me out how can i get this done.
My Pop up looks like this:
<Popup x:Name="Popupdelete"
AllowsTransparency="True"
HorizontalOffset="-10"
VerticalOffset="10"
Placement="Mouse"
StaysOpen="False"
IsOpen="{Binding IsDeletePopUpOpen}">
<Grid x:Name="LayoutRoot" Background="Transparent" Height="105">
<!-- My confirmation message and Yes No button goes Here-->
</Grid>
IsDeletePopUpOpen is set in the ViewModel.
Thanks & Regards,
Joy
Code goes here:
<-- Delete Pop Up-->
<Popup x:Name="Popupdelete"
AllowsTransparency="True"
HorizontalOffset="-10"
VerticalOffset="10"
Placement="Mouse"
StaysOpen="False"
IsOpen="{Binding IsDeletePopUpOpen}">
<Grid x:Name="LayoutRoot" Background="Transparent" Height="105">
<Border BorderBrush="#E2E2E2" BorderThickness="6" Background="White">
<Grid>
<TextBlock TextWrapping="Wrap" Margin="10,10,10,50" Foreground="#454545" FontWeight="SemiBold" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30" Width="Auto" Text="Are you sure you want" />
<TextBlock TextWrapping="Wrap" Margin="50,15,50,25" Foreground="#454545" FontWeight="SemiBold" HorizontalAlignment="Center" VerticalAlignment="Center" Height="30" Width="Auto" Text="to delete?"/>
<Button Content="Yes" Margin="35,50,80,0" Height="40" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding DeleteYesCmd}" CommandParameter="{Binding SelectedItem, ElementName=lstCustomer}" Style="{StaticResource SaveButtonStyle}" />
<TextBlock Text="or" Margin="75,50,60,15" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#919191" FontSize="10" />
<TextBlock Margin="95,48,35,12" HorizontalAlignment="Center" VerticalAlignment="Center" ><Hyperlink Command="{Binding DeleteNoCmd}"><Run Text="No" FontWeight="Bold" FontSize="12"/></Hyperlink></TextBlock>
</Grid>
</Border>
</Grid>
</Popup>
<--List Of Notes with Delete Image Button-->
<Border Background="#F0F0F0" CornerRadius="0" Visibility="{Binding NotesListViewVisibility}">
<ScrollViewer x:Name="scrollMe" CanContentScroll="True" Height="80" >
<Border Background="White" CornerRadius="5,0,0,5">
<Grid Background="White" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="101*"/>
<ColumnDefinition Width="35*"/>
</Grid.ColumnDefinitions>
<ListView x:Name="lstCustomer" BorderBrush="Transparent" BorderThickness="0" ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" RequestBringIntoView="RemoveScrollViewFocus"
ItemsSource="{Binding OutcomeNotesView , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ScrollViewer.VerticalScrollBarVisibility="Disabled" SelectionMode="Single"
Background="#FFFFFF" ItemContainerStyle="{StaticResource ListviewItemContainerStyle}" Grid.ColumnSpan="2">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UC:NoteStackPanel/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<Border BorderBrush="#E6E6E6" BorderThickness="0,0,0,1"
Width="{Binding ActualWidth, Converter={StaticResource widthconv}, ElementName=lstCustomer}">
<StackPanel x:Name="spNotes" Orientation="Vertical" Margin="0,10,0,10" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Orientation="Horizontal">
<Button x:Name="btnPrimaryOfficer" MouseEnter="SetEmployeePopUpPlacement" Style="{StaticResource AuthButton}"
CommandParameter="{Binding}" Command="{Binding DataContext.OutcomeEmployeePopUp, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}">
<Button.Visibility>
<MultiBinding Converter="{StaticResource ActiveInactiveConv}" ConverterParameter="Hyper">
<Binding Path="EmployeeInfo.ActiveStatusCode"/>
<Binding Path="EmployeeInfo.Id"/>
</MultiBinding>
</Button.Visibility>
<Button.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" CommandParameter="{Binding}"
Command="{Binding DataContext.OutcomeEmployeePopUp, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}"/>
</Button.InputBindings>
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource imgUser}" Width="15" Height="15" HorizontalAlignment="Left" />
<TextBlock Text="{Binding EmployeeInfo.Name}" Style="{StaticResource AuthEditProfile}" FontFamily="{StaticResource FontBold}" FontSize="12" Margin="2,0,0,0" />
</StackPanel>
</Button>
<StackPanel Orientation="Horizontal" >
<StackPanel.Visibility>
<MultiBinding Converter="{StaticResource ActiveInactiveConv}" ConverterParameter="Normal">
<Binding Path="EmployeeInfo.ActiveStatusCode"/>
<Binding Path="EmployeeInfo.Id"/>
</MultiBinding>
</StackPanel.Visibility>
<!--Visibility="{Binding PrimaryOfficerActiveStatusCode,Converter={StaticResource ActiveInactiveConv},ConverterParameter=Normal}">-->
<Image Source="{StaticResource imgUserBlack}" Width="15" Height="15" HorizontalAlignment="Left" />
<TextBox Text="{Binding EmployeeInfo.Name}" Style="{StaticResource TextWithoutHyperlink}" Margin="2,0,0,0" />
</StackPanel>
<TextBlock Background="Transparent" Text="on"
FontFamily="{StaticResource FontMedium}" FontSize="12" Foreground="#919191" Margin="4,0,2,0"
VerticalAlignment="Bottom" HorizontalAlignment="Center"/>
<TextBox Text="{Binding AddedDate, StringFormat=\{0:MM/dd/yy\}}" Foreground="#454545" VerticalAlignment="Bottom" MaxLength="{Binding Length}"
HorizontalAlignment="Center" Margin="2,0,0,0" Style="{StaticResource ContentText}"/>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0" HorizontalAlignment="Right" Visibility="{Binding DataContext.DeleteNoteVisibility, ElementName=OutcomeNotesView}" Orientation="Horizontal">
<StackPanel Orientation="Horizontal" >
<Button x:Name="btnDelete" Width="Auto" MouseEnter="btnDelete_MouseEnter" MouseLeave="btnDelete_MouseLeave"
CommandParameter="{Binding}"
Command="{Binding DataContext.LoadDeletePopUp, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}"
Style="{StaticResource AuthButton}">
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource imgdeleteicon}" Style="{StaticResource AuthImage}"/>
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</Grid>
<StackPanel >
<TextBox Text="{Binding Note}" Foreground="#454545" TextWrapping="Wrap" Height="Auto"
Width="{Binding ActualWidth, Converter={StaticResource widthconv}, ElementName=lstCustomer}"
Style="{StaticResource ContentText}" FontFamily="{StaticResource FontNormal}" FontSize="12" Padding="0"/>
<TextBlock x:Name="txtSavingNoteId" Visibility="Collapsed" Text="{Binding NoteId}" />
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Border>
</ScrollViewer>
</Border>
</StackPanel>
public List<ActivityNotesDto> OutcomeNotesView
{
get
{
return outcomeNotesView;
}
set
{
outcomeNotesView = value;
OnPropertyChanged("OutcomeNotesView");
}
}
DeleteActivityNote(deletingNoteDetails);
OutcomeNotesView = GetActivityNotesList();
Please let me know if i am missing something.Since first time when i click button Delete popup is opening and it is deleting but next time when i click on the Delete image it didnt open the pop up.
Thanks & Regards,
Joy

Nested Stackpanel Button Not working

I have a button nested inside two stack panels as shown by this code.
<StackPanel Grid.Row="1" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
The whole thing is in a Grid in a GroupBox of a UserControl.
The "Max UI Value Met Help" button is not working when clicked. I have similar help buttons to this in a Grid above this StackPanel that work just fine. I tried to copy and paste those in by this and they don't work either.
Why won't this button work?
Update:
I had to switch to a Grid and separate the label & button from the stack of Radio buttons to get it to work, but I want to understand why this didn't work.
The button here is in the same DataContext as the rest of my UserControl. I have multiple help buttons throughout this UserControl and they work, but this one doesn't. It doesn't matter which one I put in there either. I can move the specific button to another location and it works.
I don't like fixing something without understanding why I had to do that.
New Code:
<!--If Max UI is Met-->
<StackPanel Orientation="Horizontal" Grid.Row="1">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<StackPanel Grid.Row="2" DataContext="{StaticResource AutomaticUISettings}">
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
Here is what the code looked like before I went to Grids:
<UserControl x:Class="BogusProgram.DummyUI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:autoUIsettings="clr-namespace:BogusProgram.Resources"
xmlns:converters ="clr-namespace:BogusProgram.Converters"
xmlns:views="clr-namespace:BogusProgram.Views"
mc:Ignorable="d" >
<!--UserControl Resources-->
<UserControl.Resources>
<!--Automatic UI Settings-->
<autoUIsettings:AutoUISettings x:Key="AutomaticUISettings" />
<!--Enum to Boolean Converter-->
<converters:EnumBooleanConverter x:Key="enumBooleanConverter" />
</UserControl.Resources>
<!--UserControl Command Bindings-->
<UserControl.CommandBindings>
<!--Compare Change of all settings to Last set-->
<CommandBinding Command="{x:Static views:SetupAutoUI.CompareSettings}" Executed="CommandBinding_Executed"/>
<!--Note: Can use individual RoutedCommands per object-->
<!--http://stackoverflow.com/questions/254992/how-can-i-best-handle-wpf-radio-buttons-->
</UserControl.CommandBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--Enable/Disable Automatic UI-->
<CheckBox Content="Enable Automatic UI" IsChecked="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=AutoUIEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" x:Name="AutoUICheckbox" Margin="10,5" />
<!--Automatic UI Settings-->
<GroupBox Header="Automatic UI Settings" Grid.Row="1" Margin="10,5"
IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=AutoUIEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Set Automatic UI change by value-->
<StackPanel Orientation="Horizontal" Margin="10,5">
<Label Content="Change UI By: " />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=ChangUIby, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="CHuiBy"
TextChanged="CHuiBy_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
</StackPanel>
<!--Set when to change UI-->
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10,5">
<Label Content="Change UI Every:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=WaitPeriod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="CHuiEv"
TextChanged="CHuiEv_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Change UI Every Help-->
<Button Content="[?]" Command="{Binding ShowCHuiEvHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Change UI for-->
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="10,5" IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<Label Content="Change UI For: " />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="RunFor"
TextChanged="RunFor_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Change UI For Help-->
<Button Content="[?]" Command="{Binding ShowCHuiForHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Set Max UI value-->
<StackPanel Orientation="Horizontal" Grid.Column="1" Margin="10,5">
<Label Content="Max UI Value:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=MaxUI, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="MaxUI"
TextChanged="MaxUI_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Max UI Value Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Set Min UI value-->
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Margin="10,5">
<Label Content="Min UI Value:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=MinUI, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="MinUI"
TextChanged="MinUI_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Min UI Value Help-->
<Button Content="[?]" Command="{Binding ShowMinValueHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Enable/Disable Max Run Period-->
<CheckBox Content="Enable Max Run Period" IsChecked="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" x:Name="RunPeriodCheckbox" Margin="10" Grid.Column="1" Grid.Row="2"/>
</Grid>
<!--If Max UI is Met-->
<StackPanel Grid.Row="1" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
<!--If Min UI is Met-->
<StackPanel Grid.Row="2" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Min UI value is met" />
<!--Min UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMinValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to 255" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMax}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Max UI value" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RolltoValue}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to calculated Value" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=InvertUI}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Change UI in inverse direction" Margin="10,0" />
</StackPanel>
<!--Max Run Period-->
<StackPanel Grid.Row="3" IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DataContext="{StaticResource AutomaticUISettings}">
<!--Header-->
<Label Content="If Run Period is met" />
<!--Options-->
<RadioButton GroupName="MeetRunPeriod" IsChecked="{Binding Path=Default.RunPeriodRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetRunPeriod" IsChecked="{Binding Path=Default.RunPeriodRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Run}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Continue to running at last UI" Margin="10,0" />
</StackPanel>
</Grid>
</GroupBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Apply" Command="{Binding ApplyAutoUI}" Padding="5" Margin="10,0" IsEnabled="{Binding AutoUIChanged}" />
<Button Content="Close/Cancel" Command="{Binding CloseAutoUI}" Padding="5" Margin="10,0" />
</StackPanel>
</Grid>
actually you have to understand the diffrence between ContentTemplate and ControlTemplate of a Control( here it is Button ).
ContentTemplate says how your control content should look like with keeping all the events ans properties of the control.
ControlTemplate says how your control got overridden means it loose its all properties ans events so you have ti define them separately.means you have change the control actually.i think that you does not want.
so in place of changing ControlTemplate change its ContentTemplate like this.
<Button>
<Button.ContentTemplate>
<DataTemplate>
<contentpresenter/> // place code how your button should look like
</DataTemplate>
</Button.ContentTemplate>
<Button>

Now that I know where the focus is going to, how do I figure out why it's going there?

I have a search screen in my WPF application. The screen is implemented as a UserControl in a TabItem of a TabControl. When the user switches to the Search tab, I want the focus to go into one particular field. I asked a question here about how to figure out where the focus was going to. I now know where it's going. Now I want to figure out why it's going there so I can stop it.
Note that the focus is changing spontaneously and has nothing to do with any user activity. All the user has done is click on the search tab in the main window. The focus is supposed to go to this one particular text box; this is done in the UserControl's Loaded event handler. And it does go to that TextBox initially. Then, for some reason, it goes to the CheckBox.
I have assigned values to the TabIndex controls on my form that the user can interact with. The CheckBox is at TabIndex 1. The TextBox in question is at TabIndex 9. This is also the only TextBox on the form.
In the past, the focus would move to the TextBox and stay there. Without realizing it, I changed something that causes the focus to go to the CheckBox. I don't know what it was that I changed, exept that it was at about the time I upgraded the Telerik controls library to the latest version.
Here is the Xaml for the whole control, minus some stuff that wouldn't matter:
<UserControl x:Class="CarSystem.CustomControls.Searcher"
<!-- XML Namespaces removed for brevity -->
Height="620"
Loaded="UserControl_Loaded"
Width="990">
<UserControl.Resources>
<!--- Resource removed for brevity -->
</UserControl.Resources>
<Grid Background="{DynamicResource ContentBackground}"
FocusManager.IsFocusScope="True"
Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="110" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Column="0"
Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="0"
Grid.Row="0"
Header="Alarm Class:"
Margin="5,0">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<CheckBox Click="AllAlarmClasses_Click"
Content="ALL"
FontSize="14"
FontWeight="Bold"
Grid.Column="0"
Grid.Row="0"
HorizontalAlignment="Left"
Margin="5"
Name="AllAlarmClasses"
TabIndex="1"
VerticalAlignment="Center" />
<Button Background="{DynamicResource ButtonBackground}"
Click="ExpandPicker_Click"
Content="Expand"
FontSize="14"
FontWeight="Bold"
Grid.Column="1"
Grid.Row="0"
Foreground="{DynamicResource ButtonForeground}"
Margin="5"
Name="ExpandAlarmClass"
TabIndex="2" />
<ListBox BorderBrush="Black"
BorderThickness="1"
CheckBox.Click="AlarmClassPicker_Click"
ItemTemplate="{StaticResource CheckableChoice}"
FontSize="14"
FontWeight="Bold"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
Height="100"
ItemsSource="{Binding Path=AlarmClassChoices, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=TwoWay}"
Margin="5,0"
Name="AlarmClassPicker"
SelectionMode="Multiple"
TabIndex="3"
Visibility="Collapsed" />
</Grid>
</GroupBox>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="0"
Grid.Row="1"
Header="Source:"
Margin="5,0">
<cs:TouchComboBox Background="{DynamicResource UnfocusedBackground}"
BorderBrush="{DynamicResource ControlBorder}"
FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource UnfocusedForeground}"
GridBackground="{DynamicResource ContentBackground}"
Height="50"
IsTabStop="True"
ItemsSource="{Binding Path=HotListChoices, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=TwoWay}"
Margin="5,0"
x:Name="HotListPicker"
SelectionChanged="SourcePicker_SelectionChanged"
TabIndex="4"
TimeOfDayMode="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
VerticalAlignment="Top" />
</GroupBox>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="1"
Grid.Row="0"
Header="Start Date:"
Margin="5,0">
<telerik:RadDateTimePicker FontWeight="Bold"
Height="35"
Margin="5"
Name="StartDatePicker"
SelectionChanged="DateTimePicker_SelectionChanged"
Style="{DynamicResource RadDateTimePickerControlTemplate1}"
TabIndex="5"
VerticalAlignment="Center" />
</GroupBox>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="1"
Grid.Row="1"
Header="End Date:"
Margin="5,0">
<telerik:RadDateTimePicker FontSize="14"
FontWeight="Bold"
Height="35"
Margin="5"
Name="EndDatePicker"
SelectionChanged="DateTimePicker_SelectionChanged"
Style="{DynamicResource RadDateTimePickerControlTemplate1}"
TabIndex="6"
VerticalAlignment="Center" />
</GroupBox>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="2"
Grid.Row="0"
Header="State:"
Margin="5,0">
<cs:TouchComboBox Background="{DynamicResource UnfocusedBackground}"
BorderBrush="{DynamicResource ControlBorder}"
DisplayMemberPath="Value"
FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource UnfocusedForeground}"
GridBackground="{DynamicResource ContentBackground}"
Height="50"
ItemsSource="{Binding Path=LocaleChoices, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
Margin="5"
x:Name="StatePicker"
SelectedValue="{Binding Path=LocaleCode}"
SelectedValuePath="Key"
SelectionChanged="StatePicker_SelectionChanged"
TabIndex="7"
TimeOfDayMode="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
VerticalAlignment="Center" />
</GroupBox>
<GroupBox BorderBrush="{DynamicResource ControlBorder}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Column="2"
Grid.Row="1"
Header="Plate:"
Margin="5,0">
<Border BorderBrush="{DynamicResource ControlBorder}"
BorderThickness="1"
Height="35"
Margin="5"
VerticalAlignment="Center">
<TextBox FontSize="14"
FontWeight="Bold"
GotFocus="PlateBox_GotFocus"
LostFocus="PlateBox_LostFocus"
Margin="-1"
MaxLength="25"
MaxLines="1"
Name="PlateBox"
TabIndex="8"
Text="{Binding Path=Plate, Mode=TwoWay}"
TextChanged="PlateBox_TextChanged"
ToolTip='Wildcards ("%", "_", "[", "]") can be used' />
</Border>
</GroupBox>
</Grid>
<TabControl Background="{DynamicResource TabBackground}"
Grid.Row="1"
Margin="0,20,0,5"
Name="ResultTabs"
TabIndex="9">
<TabItem Background="{DynamicResource TabHeaderBackground}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TabHeaderForeground}"
Header="Hot List Entries:"
Name="HotListEntryTab">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<telerik:RadGridView AutoExpandGroups="True"
AutoGenerateColumns="False"
CanUserDeleteRows="False"
CanUserFreezeColumns="False"
CanUserInsertRows="False"
CanUserResizeColumns="True"
CanUserSortColumns="True"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
FontSize="14"
FontWeight="Bold"
IsReadOnly="True"
Name="HotListEntriesGrid"
SelectionChanged="HotListEntriesGrid_SelectionChanged"
SelectionUnit="FullRow"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
TabIndex="10"
ToolTip="Matching Hot List Entries">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Plate, Mode=OneWay}"
Header="Plate"
Width="*" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding LocaleCode, Mode=OneWay}"
Header="State"
Width="75" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding ListName, Mode=OneWay}"
Header="Source"
Width="150" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding AlarmClass, Mode=OneWay}"
Header="Alarm Class"
Width="150" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Notes, Mode=OneWay}"
Header="Notes"
Width="*" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<cs:ProgressControl FontSize="14"
FontWeight="Bold"
Grid.Column="0"
Grid.Row="1"
Height="55"
Margin="0,5"
x:Name="HotListProgressCtrl"
TabIndex="11"
TimeOfDayMode="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
Visibility="Collapsed" />
</Grid>
</TabItem>
<TabItem Background="{DynamicResource TabHeaderBackground}"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource TabHeaderForeground}"
Header="Reads & Alarms:"
IsSelected="True"
Name="ReadsTabItem">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<telerik:RadGridView AutoExpandGroups="True"
AutoGenerateColumns="False"
CanUserDeleteRows="False"
CanUserFreezeColumns="False"
CanUserInsertRows="False"
CanUserResizeColumns="True"
CanUserSortColumns="True"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
FontSize="14"
FontWeight="Bold"
IsReadOnly="True"
Name="ReadsGrid"
RowDetailsTemplate="{StaticResource ReadRowDetailsTemplate}"
RowStyleSelector="{StaticResource StyleSelector}"
SelectionChanged="ReadsGrid_SelectionChanged"
SelectionUnit="FullRow"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ShowGroupFooters="True"
TabIndex="12"
ToolTip="Matching Reads">
<telerik:RadGridView.Columns>
<cs:CustomGridViewToggleRowDetailsColumn IsEnabled="False"
IsFilterable="False"
IsGroupable="False"
ToggleButtonVisibility="{Binding Path=HasAlarms, Converter={StaticResource BoolToVisibility}}" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Plate, Mode=OneWay}"
Header="Plate"
Width="*" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding State, Mode=OneWay}"
Header="State"
Width="75" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding TimeStamp, Mode=OneWay, Converter={StaticResource DateConverter}}"
Header="Date & Time"
Width="150" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Latitude, Converter={StaticResource CoordConverter}, ConverterParameter=NS}"
Header="Latitude"
Width="150" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Longitude, Converter={StaticResource CoordConverter}, ConverterParameter=EW}"
Header="Longitude"
Width="150" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<cs:ProgressControl FontSize="14"
FontWeight="Bold"
Grid.Row="1"
Height="55"
Margin="0,5"
x:Name="ProgressCtrl"
TabIndex="13"
TimeOfDayMode="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
Visibility="Collapsed" />
</Grid>
</TabItem>
</TabControl>
<GridSplitter Background="{DynamicResource SeparatorColor}"
Grid.Row="1"
Height="10"
HorizontalAlignment="Stretch"
Margin="0,5"
VerticalAlignment="Top" />
<Grid Grid.Column="1"
Grid.RowSpan="2">
<Grid.RowDefinitions>
<RowDefinition Height="55" />
<RowDefinition Height="55" />
<RowDefinition Height="55" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="55" />
<RowDefinition Height="55" />
</Grid.RowDefinitions>
<Button Background="{DynamicResource ButtonBackground}"
Click="SearchButton_Click"
Content="Search"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource ButtonForeground}"
Grid.Row="0"
IsDefault="True"
Margin="5"
Name="SearchButton"
TabIndex="14" />
<Button Background="{DynamicResource ButtonBackground}"
Click="ClearButton_Click"
Content="Clear"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource ButtonForeground}"
Grid.Row="1"
Margin="5"
Name="ClearButton"
TabIndex="15" />
<Button Background="{DynamicResource ButtonBackground}"
Click="SaveCriteriaButton_Click"
FontSize="16"
FontWeight="Bold"
Grid.Row="2"
Foreground="{DynamicResource ButtonForeground}"
Margin="5"
Name="SaveCriteriaButton"
TabIndex="16"
Visibility="Visible">
<Button.Content>
<TextBlock Text="Save Report"
TextAlignment="Center"
TextWrapping="Wrap" />
</Button.Content>
</Button>
<TextBlock FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Row="4"
Margin="5"
Text="Number of Matches:"
TextAlignment="Center"
TextWrapping="Wrap" />
<TextBlock FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Row="5"
Margin="5"
Text="Hot List Entries:"
TextAlignment="Center"
TextWrapping="Wrap" />
<TextBlock FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Row="6"
Margin="5,0,5,10"
Text="{Binding Converter={StaticResource LongConverter}, ConverterParameter='#,##0', Path=NoHotListEntries, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
TextAlignment="Center"
TextWrapping="Wrap" />
<TextBlock FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Row="7"
Margin="5"
Text="Reads:"
TextAlignment="Center"
TextWrapping="Wrap" />
<TextBlock FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource TextForeground}"
Grid.Row="8"
Margin="5,0,5,10"
Text="{Binding Converter={StaticResource LongConverter}, ConverterParameter='#,##0', Path=NoReads, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
TextAlignment="Center"
TextWrapping="Wrap" />
<Button Background="{DynamicResource ButtonBackground}"
Click="ExportButton_Click"
Content="Export"
FontSize="16"
FontWeight="Bold"
Foreground="{DynamicResource ButtonForeground}"
Grid.Row="10"
Margin="5"
Name="ExportButton"
TabIndex="17" />
<Button Background="{DynamicResource ButtonBackground}"
Click="CloseButtonClicked"
Content="Close"
FontSize="20"
FontWeight="Bold"
Foreground="{DynamicResource ButtonForeground}"
Grid.Row="11"
HorizontalAlignment="Right"
Margin="5"
Name="CloseButton"
TabIndex="18"
Width="100" />
</Grid>
<Canvas Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="0"
Grid.RowSpan="4"
Name="KeyboardPopupCanvas">
<cs:KeyboardPopup x:Name="KeyboardPopup"
TimeOfDayMode="{Binding Path=TimeOfDayMode, RelativeSource={RelativeSource AncestorType={x:Type cs:Searcher}}}"
Title="Keyboard"
Visibility="Collapsed" />
</Canvas>
</Grid>
Thanks for your help
Tony
Just so that people who view this question later will know, the solution I went with was to rearrange the fields on the form so that the field I wanted to have the focus initially was the first field on the form. WPF automatically gives the focus to the control with the lowest TabIndex. Which is why my control was losing the focus after I put it there in the Loaded event handler.
I suppose that if I didn't have any TabIndex field setters in the Xaml that this would never have happened. Live and learn.

Resources