AvalonDock: How to auto-resize the control? - wpf

I seem to be unable to auto-resize an AvalonDock control when its host window is resized. (In addition, the control should dock to the full window at startup, which is also eluding me.)
I've tried the HorizontalAlignment and VerticalAlignment properties, as advised here and several other places here on SO, but they're not working for this control. No control resizing takes place when the window is resized.
From the sound of it, the properties govern resizing a control for its child controls. However, I need to resize the control with its parent (the window).
Here's my XAML, copied from the Xceed sample and modified slightly to run in my environment:
<Window
x:Class="Docker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:s="clr-namespace:System;assembly=mscorlib"
Title="AvalonDock">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="Usage:"
Style="{StaticResource Header}" />
<StackPanel Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<xcad:DockingManager x:Name="_dockingManager"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowMixedOrientation="True"
BorderBrush="Gray"
BorderThickness="1">
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconSource}"
Margin="0,0,4,0" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="200">
<xcad:LayoutAnchorable ContentId="properties"
Title="Properties"
CanHide="False"
CanClose="False"
AutoHideWidth="240"
IconSource="..\Images\table-gear.png">
<xctk:PropertyGrid NameColumnWidth="110"
SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}"
AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Background" />
<xctk:PropertyDefinition TargetProperties="BorderBrush" />
<xctk:PropertyDefinition TargetProperties="BorderThickness" />
<xctk:PropertyDefinition TargetProperties="FontSize" />
<xctk:PropertyDefinition TargetProperties="FontStyle" />
<xctk:PropertyDefinition TargetProperties="Width" />
<xctk:PropertyDefinition TargetProperties="Height" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPane>
<xcad:LayoutDocument ContentId="document1"
Title="Document 1"
IconSource="..\Images\document.png">
<Button Content="Document 1 Content"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</xcad:LayoutDocument>
<xcad:LayoutDocument ContentId="document2"
Title="Document 2"
IconSource="..\Images\document.png">
<TextBox Text="Document 2 Content"
AcceptsReturn="True" />
</xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup >
<xcad:LayoutAnchorablePaneGroup DockWidth="125">
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable ContentId="alarms"
Title="Alarms"
IconSource="..\Images\alarm.png"
CanClose="True">
<ListBox>
<s:String>Alarm 1</s:String>
<s:String>Alarm 2</s:String>
<s:String>Alarm 3</s:String>
</ListBox>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable ContentId="journal"
Title="Journal">
<RichTextBox>
<FlowDocument>
<Paragraph FontSize="14"
FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak />
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph>
</FlowDocument>
</RichTextBox>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
<xcad:LayoutRoot.LeftSide>
<xcad:LayoutAnchorSide>
<xcad:LayoutAnchorGroup>
<xcad:LayoutAnchorable Title="Agenda"
ContentId="agenda"
IconSource="..\Images\book_open.png">
<TextBlock Text="Agenda Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable Title="Contacts"
ContentId="contacts"
IconSource="..\Images\address_book-edit.png">
<TextBlock Text="Contacts Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorGroup>
</xcad:LayoutAnchorSide>
</xcad:LayoutRoot.LeftSide>
</xcad:LayoutRoot>
</xcad:DockingManager>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<Button Content="Save AvalonDock"
Margin="5"
Padding="5"
Click="SaveButton_Click" />
<Button Content="Load AvalonDock"
Margin="5"
Padding="5"
Click="LoadButton_Click" />
</StackPanel>
</StackPanel>
</Grid>
</Window>

Get rid of the StackPanel on the second row of the Grid. A StackPanel doesn't resize its children.
Also note that the default values of the HorizontalAlignment and the VerticalAlignment of a Grid are both Stretch so you don't need to set these explicitly.
Try this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Usage:" Style="{StaticResource Header}" />
<xcad:DockingManager x:Name="_dockingManager"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowMixedOrientation="True"
Grid.Row="1"
BorderBrush="Gray"
BorderThickness="1">
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconSource}"
Margin="0,0,4,0" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="200">
<xcad:LayoutAnchorable ContentId="properties"
Title="Properties"
CanHide="False"
CanClose="False"
AutoHideWidth="240"
IconSource="..\Images\table-gear.png">
<xctk:PropertyGrid NameColumnWidth="110"
SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}"
AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Background" />
<xctk:PropertyDefinition TargetProperties="BorderBrush" />
<xctk:PropertyDefinition TargetProperties="BorderThickness" />
<xctk:PropertyDefinition TargetProperties="FontSize" />
<xctk:PropertyDefinition TargetProperties="FontStyle" />
<xctk:PropertyDefinition TargetProperties="Width" />
<xctk:PropertyDefinition TargetProperties="Height" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPane>
<xcad:LayoutDocument ContentId="document1"
Title="Document 1"
IconSource="..\Images\document.png">
<Button Content="Document 1 Content"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</xcad:LayoutDocument>
<xcad:LayoutDocument ContentId="document2"
Title="Document 2"
IconSource="..\Images\document.png">
<TextBox Text="Document 2 Content"
AcceptsReturn="True" />
</xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup >
<xcad:LayoutAnchorablePaneGroup DockWidth="125">
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable ContentId="alarms"
Title="Alarms"
IconSource="..\Images\alarm.png"
CanClose="True">
<ListBox>
<s:String>Alarm 1</s:String>
<s:String>Alarm 2</s:String>
<s:String>Alarm 3</s:String>
</ListBox>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable ContentId="journal"
Title="Journal">
<RichTextBox>
<FlowDocument>
<Paragraph FontSize="14"
FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak />
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph>
</FlowDocument>
</RichTextBox>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
<xcad:LayoutRoot.LeftSide>
<xcad:LayoutAnchorSide>
<xcad:LayoutAnchorGroup>
<xcad:LayoutAnchorable Title="Agenda"
ContentId="agenda"
IconSource="..\Images\book_open.png">
<TextBlock Text="Agenda Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable Title="Contacts"
ContentId="contacts"
IconSource="..\Images\address_book-edit.png">
<TextBlock Text="Contacts Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorGroup>
</xcad:LayoutAnchorSide>
</xcad:LayoutRoot.LeftSide>
</xcad:LayoutRoot>
</xcad:DockingManager>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Save AvalonDock"
Margin="5"
Padding="5"
Click="SaveButton_Click" />
<Button Content="Load AvalonDock"
Margin="5"
Padding="5"
Click="LoadButton_Click" />
</StackPanel>
</Grid>

Related

How to avoid overlapping of content in dockpanel

I have two stackpanel inside Dock Panel. When the window is resizing the top panel is overlapping the bottom one.
<Grid>
<DockPanel DockPanel.Dock="Left" LastChildFill="True" Width="{Binding ActualWidth, ElementName=characterLength}">
<!-- Batch information panel: Top -->
<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
<TextBlock x:Name="ReadOnlyNoBatchesTextBlock"
DockPanel.Dock="Top"
Text="no batch"
FontSize="19" HorizontalAlignment="left" AutomationProperties.AutomationId="DipIn_BatchReviewView_NoBatches_Text"
FontWeight="Bold"
/>
<TextBlock HorizontalAlignment="Left" FontSize="19" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchNumber_Text" />
<TextBlock Text="status" HorizontalAlignment="Left" Margin="0,6,0,0" FontSize="16" FontWeight="Bold"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmissionStatus_Text">
</TextBlock>
<TextBlock Text="submitted" FontSize="14" HorizontalAlignment="Left"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedAt_Text">
</TextBlock>
<TextBlock Text="qeqweq" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedBy_Text" />
<TextBlock Text="ertert" FontSize="16" HorizontalAlignment="Left" Margin="0,6,0,0" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressed_Text">
</TextBlock>
<TextBlock Text="dsdfgfdg" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressedAt_Text" >
</TextBlock>
<!-- Must be last item in the stack panel otherwise you get a vertical gap-->
<TextBlock Grid.Column="0" x:Name="characterLength" Text="abcdefg" HorizontalAlignment="Left" Visibility="Hidden" FontWeight="Bold" FontSize="14" />
</StackPanel>
</ScrollViewer>
<!-- Button panel: Bottom -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SetMarkerStandardised_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3"
AutomationProperties.AutomationId="DipIn_BatchReviewView_AllocateNextStandardisationBatch_Button" />
<!-- Content, Automation Id & Command is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_AutoProgressBatches_Button" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchListFilter_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SubmitBatch_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_StartStop_Marker_Button">
<TextBlock FontSize="14" Text="a" />
</Button>
</StackPanel>
</DockPanel>
</Grid>
I need that when window is resizing bottom panel should always be visible and top panel will get scroll bar.
I have tried many ways but still getting the same issue from this code the top one will get the scroll bar but only when the bottom one will go invisible
<Grid>
<DockPanel>
<!--<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">-->
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
<TextBlock x:Name="ReadOnlyNoBatchesTextBlock"
DockPanel.Dock="Top"
Text="no batch"
FontSize="19" HorizontalAlignment="left" AutomationProperties.AutomationId="DipIn_BatchReviewView_NoBatches_Text"
FontWeight="Bold"
/>
<TextBlock HorizontalAlignment="Left" FontSize="19" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchNumber_Text" />
<TextBlock Text="status" HorizontalAlignment="Left" Margin="0,6,0,0" FontSize="16" FontWeight="Bold"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmissionStatus_Text">
</TextBlock>
<TextBlock Text="submitted" FontSize="14" HorizontalAlignment="Left"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedAt_Text">
</TextBlock>
<TextBlock Text="qeqweq" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedBy_Text" />
<TextBlock Text="ertert" FontSize="16" HorizontalAlignment="Left" Margin="0,6,0,0" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressed_Text">
</TextBlock>
<TextBlock Text="dsdfgfdg" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressedAt_Text" >
</TextBlock>
<!-- Must be last item in the stack panel otherwise you get a vertical gap-->
<TextBlock Grid.Column="0" x:Name="characterLength" Text="abcdefg" HorizontalAlignment="Left" Visibility="Hidden" FontWeight="Bold" FontSize="14" />
</StackPanel>
<!--</ScrollViewer>-->
<!-- Button panel: Bottom -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SetMarkerStandardised_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3"
AutomationProperties.AutomationId="DipIn_BatchReviewView_AllocateNextStandardisationBatch_Button" />
<!-- Content, Automation Id & Command is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_AutoProgressBatches_Button" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchListFilter_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SubmitBatch_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_StartStop_Marker_Button">
<TextBlock FontSize="14" Text="a" />
</Button>
</StackPanel>
</DockPanel>
</Grid>
Avoid using ScrollViewer it will Avoid the Overlapping of the Content .
You could use a Grid with two RowDefinitions:
<DockPanel DockPanel.Dock="Left" LastChildFill="True" Width="{Binding ActualWidth, ElementName=characterLength}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
...
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="1" Orientation="Vertical" VerticalAlignment="Bottom">
...
</StackPanel>
</Grid>
</DockPanel>

ListBoxItem Should be Visible while Draging From one ListBox to another in WPF

Click Here to View ImageI am implementing Drag& Drop in wpf. I want when i dragged ListBoxItem From one Listbox to another. that listboxitem should be visible while dragging.Do i missing Something ?
XAML
<Grid x:Name="MainGrid" Width="{Binding ElementName=ProjectWindow,Path=ActualWidth}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*" />
<ColumnDefinition Width="283*" />
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="19*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="7*" />
<RowDefinition Height="83*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="0" >
<Label Content="TM" FontSize="14" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="118" Canvas.Top="-4"></Label>
<Label Content="smart" FontSize="26" Foreground="White" FontFamily="segoe_uilight"></Label>
<Label Content="Project" FontSize="26" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="64" FontWeight="Bold"></Label>
<TextBlock Canvas.Left="164" Canvas.Top="15" Background="Black">
<Label Background="Black" Content="From" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="164" Canvas.Top="15" ></Label>
<DatePicker x:Name="StartDate" Width="100" Background="Black" Canvas.Left="204" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="Till" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<DatePicker x:Name="EndDate" Width="100" Background="Black" Canvas.Left="344" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="My Activities" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<CheckBox x:Name="ChckBoxMyActivities" Click="ChckBoxMyActivities_Click_1" Background="Black" Margin="0,0,0,5" Width="20"></CheckBox>
<Label Background="Black" Content="Project Component" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<ComboBox x:Name="ComboBoxSubProjects" SelectionChanged="ComboBoxSubProjects_SelectionChanged_1" Background="Black" Margin="0,0,0,5" Width="100" ></ComboBox>
</TextBlock>
<Expander HorizontalAlignment="Right" FlowDirection="RightToLeft" Foreground="White" FontFamily="segoe_uilight" Width="200px" Canvas.Top="1" Canvas.Right="200" Canvas.Left="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}" BorderBrush="#FF0A0909" BorderThickness="1,1,1,2" Background="#BF080707" Panel.ZIndex="99999">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Canvas Height="22" Width="172px" VerticalAlignment="Bottom">
<Label x:Name="LoginUserName" Margin="0px 0 0 0" HorizontalAlignment="Left" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0"></Label>
<Image Source="img\icons\dropdown_user.png" Height="20px" Width="20px" RenderTransformOrigin="2.75,0.8" Canvas.Left="117" />
</Canvas>
</StackPanel>
</Expander.Header>
<!--<Expander.Content>
<TextBox Text="LoginUserName"></TextBox>
</Expander.Content>-->
<StackPanel Margin="10,4,0,0" >
<StackPanel Orientation="Horizontal">
<Label x:Name="lblSettings" Margin="49px 0 31px 0" HorizontalAlignment="Left" Content="Settings" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" RenderTransformOrigin="2.019,0.625">
</Label>
<Image Source="img\icons\setting.png" Height="20px" Width="20px" />
</StackPanel>
<!--<Label Margin="4" Content="Logout" />-->
<!--<Button x:Name="btnLogout" Margin="4" Content="Logout" Click="btnLogout_Click_1"></Button>-->
<StackPanel Orientation="Horizontal">
<Label x:Name="btnLogout" HorizontalAlignment="Left" Margin="54px 0 31px 0" Content="Logout" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0">
</Label>
<Image Source="img\icons\logout.png" Height="20px" Width="20px" />
</StackPanel>
</StackPanel>
</Expander>
</Canvas>
<Canvas Grid.Column="0" Grid.Row="1" Background="Orange">
<StackPanel Canvas.Left="10" Background="Gray" Width="60" >
<Image Source="img\icons\information.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="45" Background="Gray" Width="60" >
<Image Source="img\icons\Scheme.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Schema" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\Tavala.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Tavla" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
<Canvas x:Name="gd" Grid.Column="1" Grid.Row="1" Panel.ZIndex="-1" Background="Orange">
<Grid Width="{Binding ElementName=gd, Path=ActualWidth}" Panel.ZIndex="-1">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Canvas Grid.Column="1" Grid.Row="0" >
<Canvas x:Name="MainCanvas" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBoxItem>
<ListBox Loaded="icTodoList_Loaded_1" Background="Azure" SelectionChanged="icTodoList_SelectionChanged_1" Name="icTodoList" Height="50" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="Phases" BorderThickness="0">
<ListBoxItem>
<Canvas x:Name="PhaseCanvas" Height="20" Width="200" Margin="0,0,20,20" >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtPhaseID" TextAlignment="Center" FontWeight="Light" HorizontalAlignment="Center" FontSize="16" Foreground="Black" FontFamily="segoe_uilight" Text="{Binding PhaseTitle}" Height="20" Width="140" />
<Image Margin="20,0,0,0" Tag="{Binding PhaseID}" Source="img\icons\add_btn.png" Width="20" Height="15" MouseUp="Image_MouseUp_1"></Image>
<!--<TextBlock HorizontalAlignment="Left" FontFamily="segoe_uilight" FontStyle="Italic" Text="{Binding UserName}" Height="20" Width="180" />
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="segoe_uilight" Text="{Binding ThreadDescription}" Height="45" Width="200" />-->
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
<ListBoxItem>
<ListBox Loaded="ActivityListBox_Loaded_1" Background="Orange" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="InnerActivityListBox" Tag="{Binding PhaseID}" Width="225" Height="{Binding ElementName=gd,Path=ActualHeight}" Background="Orange" PreviewMouseLeftButtonDown="InnerActivityListBox_PreviewMouseLeftButtonDown_1" AllowDrop="True" DragEnter="InnerActivityListBox_DragEnter_1" Drop="InnerActivityListBox_Drop_1" DragOver="InnerActivityListBox_DragOver_1" BorderThickness="0">
<!--<ListBoxItem>-->
<!--<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>-->
<!--</ListBoxItem>-->
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
</ListBox>
<!--<ListBox Loaded="ActivityListBox_Loaded_1" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Canvas.Top="100" Width="{Binding ElementName=gd,Path=ActualWidth}" Background="Orange">
<ListBox.ItemTemplate >
<DataTemplate>
<ListBox x:Name="InnerActivityListBox">
<ListBoxItem>
<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>-->
<!--<Canvas Width="200" Height="50" Background="White" Canvas.Left="46" Canvas.Top="10">
<TextBlock FontWeight="Bold" Height="50" Width="10" Canvas.Left="0" Background="Gray"></TextBlock>
<TextBlock Text="Header Style" FontWeight="Bold" Canvas.Top="2" Canvas.Left="15"></TextBlock>
<TextBlock Text="Schedule" Canvas.Top="14" Canvas.Left="15"></TextBlock>
<TextBlock Text="1 Jan-3Mar" Canvas.Top="7" Canvas.Left="110"></TextBlock>
<Image Source="img/icons/icon.png" Canvas.Left="15" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_1.png" Canvas.Left="45" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_2.png" Canvas.Left="75" Canvas.Bottom="5"></Image>
<Image Source="img/icons/t3.png" Canvas.Left="105" Canvas.Bottom="5"></Image>
</Canvas>-->
</Canvas>
</Canvas>
</Grid>
</Canvas>
<Canvas x:Name="cn" Grid.Column="2" Grid.Row="1" Background="White" MouseUp="Canvas_MouseUp_1">
<!--`ActivityInfo Popup up-->
<Canvas x:Name="ActivityInfo" Background="Green" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="ActivityInfo_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="projectdescrption" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Information" Canvas.Left="10" ></TextBlock>
<Canvas Background="White" Height="900" Width="200" Canvas.Top="50" Canvas.Left="10">
<StackPanel Width="200" Height="900" Background="White" Orientation="Vertical" >
<TextBlock x:Name="ActivityTitle" Text="Title" FontFamily="segoe_uilight" FontSize="18" Foreground="Black"></TextBlock>
<TextBlock x:Name="txtActivityTitle" Text="Page Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ProjectCompnt" Text="Project Component" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtProjectCompnt" Text="Project Component Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Phase" Text="Phase" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtPhase" Text="Phase Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Start" Text="Start" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtStart" Text="2014-1-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="End" Text="End" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtEnd" Text="2014-2-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Activitydescrption" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Description" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivitydescrption" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ActivityRequirement" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Requirement" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivityRequirement" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<Button x:Name="btnsave" Content="Save" Foreground="Black" Height="30" Width="100" HorizontalAlignment="Right" Background="#FFF3800C"></Button>
</StackPanel>
</Canvas>
</Canvas>
<!--`Activity Comments-->
<Canvas x:Name="Comments" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="Comments_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="ActivityComments" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="23" Text="Comments" Canvas.Left="35"></TextBlock>
<TextBox x:Name="txtComments" Height="110" Width="200" BorderBrush="Black" TextWrapping="Wrap" Canvas.Top="40" Canvas.Left="5" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"></TextBox>
<Button x:Name="btnsavecomments" Content="Send" Foreground="Black" Height="30" Width="100" Canvas.Top="170" Canvas.Left="35" Background="#FFF3800C"></Button>
<ListBox Canvas.Top="220" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" >
<Border BorderThickness="2,2,2,2" CornerRadius="4" Background="#E26806">
<TextBlock x:Name="txtthreadComments" Height="Auto" Width="190" TextWrapping="Wrap" Background="#E26806" Text="g rg rg r g rg rg rg rg er gre ger ger g g gr" Foreground="White" ></TextBlock>
</Border>
<Image x:Name="imgthread" Height="30" Width="30" Margin="-100,-12,0,0" Source="D:\Amrit\Working Code\smart Info WPF app\SmartInfo\SmartAccount\SmartAccount\img\tol_tip.jpg"></Image>
<TextBlock x:Name="threadtime" Text="2014-6-7 12:00" HorizontalAlignment="Stretch" Margin="0,0,10,0" FontStyle="Italic" Height="20" Width="150" Foreground="Black" FontSize="16"></TextBlock>
<TextBlock x:Name="threadPostedBy" Text="Amrit Verma" Height="20" Width="150" Foreground="Black" FontStyle="Italic" FontWeight="Bold" FontSize="15"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
<!-- Assigned Memebres -->
<Canvas x:Name="AssignedMemebres" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" Visibility="Hidden">
<TextBlock x:Name="Memebres" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Assigned Members" Canvas.Left="30"></TextBlock>
<ListBox Canvas.Top="40" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<TextBlock x:Name="AssignMemeber" Foreground="Black" FontFamily="segoe_uilight" FontSize="14" Text="+ Assign Memeber" FontStyle="Italic" Canvas.Left="12" Canvas.Top="-3"></TextBlock>
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" Canvas.Left="20">
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedto" Text="Amrit Verma" FontWeight="Bold"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedrole" Text="Developer" ></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Email" Text="Email" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtEmail" Text="Amrit#gmail.com" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Phone" Text="Phone" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtPhone" Text="555-111 442 213" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingHours" Text="Working Hours" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingHours" Text="9:00 - 12:00" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingDays" Text="Working Days" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingDays" Text="Mon-Sat" FontStyle="Italic"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
</Canvas>
<Canvas Grid.Column="3" Grid.Row="1" Background="Orange" >
<StackPanel Canvas.Left="0" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_1" x:Name="stackpnlinfo">
<Image Source="img\icons\icon.png" Height="20px" Width="20px" />
<!--<Image Source="img\btn_img.jpg" Height="45px" Width="60px" />-->
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" ></Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="45" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_2" x:Name="stackpnlcomment">
<Image Source="img\icons\icon_1.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Comments" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\icon_2.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Files" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="135" Background="Gray" Width="60" x:Name="AssignedMembrs" MouseUp="AssignedMembrs_MouseUp_1">
<Image Source="img\icons\at.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Assigned Members" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
</Grid>
c#
private void InnerActivityListBox_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
if (_dragged != null)
return;
UIElement element = Phaseitem.InputHitTest(e.GetPosition(Phaseitem)) as UIElement;
while (element != null)
{
if (element is ListBoxItem)
{
_dragged = (ListBoxItem)element;
break;
}
element = VisualTreeHelper.GetParent(element) as UIElement;
}
SourcePhaseID = Phaseitem.Tag.ToString();
Globallb = Phaseitem;
Globallbi = _dragged;
Phaseitem.Items.Remove(_dragged);
}
private void InnerActivityListBox_DragEnter_1(object sender, DragEventArgs e)
{
if (_dragged == null || e.Data.GetDataPresent(DataFormats.Text, true) == false)
e.Effects = DragDropEffects.None;
else
e.Effects = DragDropEffects.All;
}
private void InnerActivityListBox_Drop_1(object sender, DragEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
DestinationPhaseID = Phaseitem.Tag.ToString();
Phaseitem.Items.Add(_dragged);
}
private void InnerActivityListBox_DragOver_1(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
If this is you are trying to achieve. This also include designing your own Adorner to be shown as Ghost Perview while dragging
http://www.codeproject.com/Articles/43702/Drag-and-Drop-in-WPF-Part-II
and this article has vanilla code and doing exactly what you want
http://www.essentialobjects.com/doc/5/controls/treeview/dragdrop.aspx#list_box

Specific layout for Windows Phone 7

I would like to create this layout in Silverlight. The text need to wrap around the picture :
The closest solution i find is that but this is not exactly what i would like.
<StackPanel Margin="0,0,0,20">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<StackPanel Orientation="Horizontal" >
<Image Source="{Binding Img}" MaxWidth="100" />
<TextBlock Text="{Binding Desc}" TextWrapping="Wrap" Margin="0,10,0,5" Style="{StaticResource PhoneTextSubtleStyle}"/>
</StackPanel>
</StackPanel>
Best I can come up with is to use a grid
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="40" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<TextBlock Text="Title" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" />
<TextBlock Text="Image" Grid.Row="1" Grid.Column="0" />
<TextBlock Text="Description" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" />
</Grid>
Another Suggestion would be to use the RichTextBox. I got not too bad results using
<RichTextBox Width="400" Height="400" FontSize="40">
<Paragraph>
<InlineUIContainer >
<Image Source="/image.png" Width="100" Height="200" />
</InlineUIContainer>
<Run Text="A simple RichTextBox with Image: " />
<Italic Foreground="YellowGreen">Some Italic Text Here!</Italic>
</Paragraph>
</RichTextBox>

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.

WPF: Align last TWO controls in StackPanel/DockPanel on the very right side

Thats my code so far which does not work:
<DockPanel >
<Button Content="Start" Command="{Binding Path=FirstDateCommand}" />
<Button Content="Back" Command="{Binding Path=PreviousDateCommand}" />
<DatePicker Width="150"
SelectedDate="{Binding Path=SelectedDate}"
DisplayDateStart="{Binding Path=MinDate}"
DisplayDateEnd="{Binding Path=MaxDate}" SelectedDateFormat="Long" />
<Button Content="Forward" Command="{Binding Path=NextDateCommand}" />
<Button Content="End" Command="{Binding Path=LastDateCommand}" />
<Button Command="{Binding PrintCommand}" Content="Print Planner" />
<Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs" />
<Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
<Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
<TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />
<Button Command="{Binding FindAllCommand}" Content="Search" />
<DockPanel DockPanel.Dock="Right" HorizontalAlignment="Right">
<TextBlock Text="class code:" VerticalAlignment="Center" />
<ComboBox
ItemsSource="{Binding GroupViewModelList}"
Style="{StaticResource GroupViewModelStyle}"
ItemTemplate="{StaticResource GroupViewModelItemTemplate}"
Width="100"/>
</DockPanel>
</DockPanel>
How can I set the 2 last controls on the image on the very right side?
UPDATE:
<Grid Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Margin="10,10,10,0" Grid.Row="0" Name="ButtonBar">
<StackPanel FocusManager.IsFocusScope="True" Orientation="Horizontal">
<ComboBox
AlternationCount="2"
FontSize="16"
VerticalContentAlignment="Center"
Width="100"
ItemContainerStyle="{StaticResource alternateColor}"
ItemsSource="{Binding Source={x:Static Member=Fonts.SystemFontFamilies}}" x:Name="fontComboFast">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VirtualizingStackPanel.VirtualizationMode="Recycling" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="100" Text="{Binding}" FontFamily="{Binding }" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!--<View:FormatButtonBar />-->
<View:DateNavigatorView />
<View:LessonPlannerView />
<!--<View:TextFormatBarUC />-->
</StackPanel>
</Grid>
The 2 controls are in the LessonPlannerView (UserControl)
Inside the LessonPlannerView you find this code:
...
<Grid >
<DockPanel>
<Button Command="{Binding PrintCommand}" Content="Print Planner" />
<Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs" />
<Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
<Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
<TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />
<Button Command="{Binding FindAllCommand}" Content="Search" />
<StackPanel x:Name="ClassCodeChooser" Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right">
<TextBlock Text="class code:" VerticalAlignment="Center" />
<ComboBox ItemsSource="{Binding SchoolclassCodeList}"
/>
</StackPanel>
</DockPanel>
</Grid>
</UserControl>
That should be fine but you really don't need the nested DockPanel's. You could change the inner DockPanel to a horizontal StackPanel.
But the real problem is that your outer DockPanel doesn't seem to be expanding to the full width of its container. Set a Background on the outer DockPanel to give you a visual indication of why it isn't filling out its container.
In response to the comment thread below, adding the following example
<Grid Name="ButtonBar">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0">
<View:FormatButtonBar /> <!-- this will dock left -->
<View:DateNavigatorView /> <!-- this will dock left -->
<View:LessonPlannerView /> <!-- this will dock left -->
<View:TextFormatBarUC /> <!-- this will fill -->
</DockPanel>
</Grid>

Resources