Canvas Z Order issue - wpf

Im trying to render a bunch of ellipses with lines coming out from the center, in north, east, south and west directions.
However, I also need all ellipses to be on top of all lines, not just on top of its own lines.
With the following code, I can't do this as each item template has its own canvas, and so setting the zindex wont help.
Any ideas of how I could solve this?
<Window x:Class="WpfApplication27.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="800" Width="800">
<ItemsControl ItemsSource="{Binding Nodes}">
<ItemsControl.Template>
<ControlTemplate>
<Grid>
<Canvas Name="PART_Canvas" IsItemsHost="True"/>
</Grid>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Canvas>
<Line X1="25" Y1="25" X2="25" Y2="125" Stroke="Black"/>
<Line X1="25" Y1="25" X2="25" Y2="-75" Stroke="Black"/>
<Line X1="25" Y1="25" X2="125" Y2="25" Stroke="Black"/>
<Line X1="25" Y1="25" X2="-75" Y2="25" Stroke="Black"/>
<Ellipse Width="50" Height="50" Fill="Red"/>
</Canvas>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Window>

You could add 2 ItemsCotrols on top of each other bound to the same collection, the back one would render the lines and the front one renders the ellipse's
<Grid>
<Grid.Resources>
<Style x:Key="NodeContainer" TargetType="ContentPresenter">
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</Grid.Resources>
<!--Line-->
<ItemsControl ItemsSource="{Binding Nodes}" ItemContainerStyle="{StaticResource NodeContainer}">
<ItemsControl.Template>
<ControlTemplate>
<Grid>
<Canvas Name="PART_CanvasBack" IsItemsHost="True"/>
</Grid>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Canvas>
<Line X1="25" Y1="25" X2="25" Y2="125" Stroke="Black"/>
<Line X1="25" Y1="25" X2="25" Y2="-75" Stroke="Black"/>
<Line X1="25" Y1="25" X2="125" Y2="25" Stroke="Black"/>
<Line X1="25" Y1="25" X2="-75" Y2="25" Stroke="Black"/>
</Canvas>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!--Ellipse-->
<ItemsControl ItemsSource="{Binding Nodes}" ItemContainerStyle="{StaticResource NodeContainer}">
<ItemsControl.Template>
<ControlTemplate>
<Grid>
<Canvas Name="PART_CanvasFront" IsItemsHost="True"/>
</Grid>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Canvas>
<Ellipse Width="50" Height="50" Fill="Red"/>
</Canvas>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>

Related

Changing ModalDialog Title bar background color

We have a WPF windows application, We need to change the Modal dialog title bar color, Below is the code snippet and also the screenshot of current dialog box. We are using WPF DevExpress.Xpf third party dlls.
We have tried background color change option also at various places but nothing works and title bar colro wont get changed.
<coreClient:BaseWindow x:Name="ModalDialogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ShowInTaskbar="False"
Height="10" Width="10"
Activated="ModalDialogWindowActivated"
Icon="/Images/app_icon_small.png"
Title="{Binding Path=DialogTitle}">
<coreClient:BaseWindow.Resources>
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converter:EmptyStringToVisibilityConverter x:Key="EmptyStringToVisibilityConverter" />
<converter:ModalDialogActionCommandArgsConverter x:Key="ModalDialogActionCommandArgsConverter" />
</coreClient:BaseWindow.Resources>
<DockPanel LastChildFill="True">
<Border Height="35" DockPanel.Dock="Bottom" Margin="0" Style="{StaticResource BdrModalDialogActionPanel}">
<DockPanel LastChildFill="True">
<StackPanel x:Name="actionButtonPanel"
Orientation="Horizontal"
DockPanel.Dock="Right"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<ItemsControl Name="actionButtons"
ItemsSource="{Binding ActionButtons}"
HorizontalAlignment="Right"
Focusable="False"
VerticalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="additionalActionButton"
IsDefault="{Binding IsButtonDefault}"
IsCancel="{Binding IsButtonCancel}"
IsEnabled="{Binding IsButtonEnabled}"
Content="{Binding Path=Content}"
HorizontalAlignment="Center" VerticalAlignment="Center"
Margin="0,0,5,0"
ToolTipService.ShowOnDisabled="True"
Command="{Binding Path=ActionCommand}" Height="29">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource ModalDialogActionCommandArgsConverter}">
<MultiBinding.Bindings>
<Binding ElementName="ModalDialogWindow" />
<Binding />
</MultiBinding.Bindings>
</MultiBinding>
</Button.CommandParameter>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="Content" Value="Search">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Height" Value="29" />
<Setter Property="Width" Value="76" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="#0096d6" x:Name="RootElement">
<TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.ToolTip>
<ToolTip Visibility="{Binding TooltipText, Converter={StaticResource EmptyStringToVisibilityConverter}, ConverterParameter='HIDDEN'}"
Content="{Binding TooltipText}" />
</Button.ToolTip>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<StackPanel Orientation="Horizontal"
DockPanel.Dock="Left"
Visibility="{Binding IsActionInProgress, Converter={StaticResource BoolToVisibilityConverter}}">
<common:SpinnerControl x:Name="SpinnerControl" VerticalAlignment="Center" VerticalContentAlignment="Center" />
<TextBlock Text="{Binding ActionStatusMessage}"
Margin="5,0,0,0"
VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>
<ContentControl x:Name="MainControl"
IsTabStop="False"
Focusable="False" />
</DockPanel>
</coreClient:BaseWindow>

How can I transform a border but not the content inside?

Here is an image of my problem and my code below. I'd like to know how I can get the text to be flipped right side up. Below is also a link where I got the suggestions for setting scale transform Y to 1.
https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-flip-a-uielement-horizontally-or-vertically
<Viewbox>
<Grid>
<ItemsControl ItemsSource="{Binding FaceParts}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Background="SlateBlue" Height="140" Width="80" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="RenderTransform" Value="1 0 0 -1 0 0"/>
<Setter Property="Canvas.Left" Value="{Binding X}"/>
<Setter Property="Canvas.Top" Value="{Binding Y}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<Border Width="{Binding Width}" Height="{Binding Height}" Background="{Binding Fill}" BorderBrush="Black" BorderThickness=".20">
<Viewbox>
<TextBlock Text="{Binding TextOverlay}" RenderTransformOrigin=".5,.5">
<TextBlock.RenderTransform>
<ScaleTransform ScaleY="1"/>
</TextBlock.RenderTransform>
</TextBlock>
</Viewbox>
</Border>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Viewbox VerticalAlignment="Bottom" Height="5" Margin="0,0,0,5">
<TextBlock Background="SlateBlue" TextAlignment="Center" Text="{Binding SelectedViewerProduct.Width, Converter={StaticResource FractionConverter}}"/>
</Viewbox>
</Grid>
</Viewbox>
As it turns out, setting ScaleY to a positive has no effect on flipping it right side up, in order to flip it right side up, I had to set the ScaleY to a -1. Essentially flipping it over again the opposite direction to make it right side up.

wpf Select Multiple ListboxItems(i.e, Images) using Keyboard[Ctrl + RightArrow/leftArrow]

I Have grouped the listbox items,i can able to select "Multiple" items by SelectionMode="Extended" or "Multiple". Now i have got two issues and one more thing in "Sorting"
When
[ SelectionMode="Extended"]
i can select Multiple Items by pressing and selecting the items using Mouse, once i move the mouse to the others controls,i'm losing my selection.
2.I'm unable to select Multiple items using Keyboard and unable to travel to listboxItems(i.e,) "Images" using Arrow Keys.
I want to sort/Arrange the grouped Items.
could anybody guide over these..thnx in advance.
<CollectionViewSource x:Key="CharacterCollectionView"
Source="{Binding}" >
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Name" />
</CollectionViewSource.GroupDescriptions>
<!--<CollectionViewSource.SortDescriptions>
<cm:SortDescription PropertyName="First" />
</CollectionViewSource.SortDescriptions>-->
</CollectionViewSource>
<ItemsPanelTemplate x:Key="HorizontalItemsPanel">
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" />
</ItemsPanelTemplate>
<Style x:Key="myListboxStyle">
<Style.Resources>
<!-- Background of selected item when focussed -->
<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#66000000" Offset="0" />
<GradientStop Color="#33000000" Offset="1" />
</LinearGradientBrush>
<!-- Background of selected item when not focussed -->
<LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="#66000000" Offset="0" />
<GradientStop Color="#33000000" Offset="1" />
</LinearGradientBrush>
</Style.Resources>
</Style>
</Window.Resources>
<DockPanel>
<StackPanel Orientation="Vertical" DockPanel.Dock="Left" Background="#336699" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<ListBox
Margin="20,20,20,5" DataContext="{Binding}"
ItemsSource="{Binding Source={StaticResource CharacterCollectionView}}"
DockPanel.Dock="Top" x:Name="MyList" MouseEnter="MyListEvent"
Width="700" SelectionMode="Extended" Style="{StaticResource myListboxStyle }"
Height="700" Background="LightGray" IsSynchronizedWithCurrentItem="True"
ScrollViewer.CanContentScroll="True" SelectedIndex="1"
ScrollViewer.VerticalScrollBarVisibility="Visible" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" PresentationTraceSources.TraceLevel="High" >
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="1"/>
<Setter Property="BorderBrush" Value="Green"/>
<Setter Property="Width" Value="{Binding Path=Value, ElementName=sizeSlider, Mode=TwoWay}"/>
<Setter Property="Height" Value="{Binding Path=Value, ElementName=sizeSlider, Mode=TwoWay}"/>
<!--<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsSelected" Value="True" />
</Trigger>
</Style.Triggers>-->
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="LightSteelBlue" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Viewbox Stretch="Fill" HorizontalAlignment="Stretch" >
<Border BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding}" BorderBrush="IndianRed" Margin="0" Height="Auto">
<DockPanel>
<Image
DockPanel.Dock="Top"
Width="150" Margin="5"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Height="Auto" x:Name="Myimage"
Source="{Binding Path=ImageFilepath[0]}"/>
<Grid>
<Label Content="{Binding Path=Name[0]}" HorizontalContentAlignment="Center" FontWeight="Normal" FontSize="13" />
</Grid>
</DockPanel>
</Border>
</Viewbox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" FontSize="18" Height="Auto" Background="Transparent" FontWeight="Medium" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Background="White" />
</ItemsPanelTemplate>
</GroupStyle.Panel>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<GroupBox Header="{Binding Name}" BorderBrush="#336699" BorderThickness="2" Margin="5">
<ItemsPresenter />
</GroupBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListBox.GroupStyle>
</ListBox>
<StackPanel Grid.Row="1" HorizontalAlignment="Center" Orientation="Horizontal" Margin="2,0,5,5">
<TextBlock Width="Auto" Text="Min" Foreground="White" FontWeight="Bold" FontSize="14" Margin="2" Padding="0" HorizontalAlignment="Right" />
<Slider
Name="sizeSlider"
Width="300" Orientation="Horizontal"
Value="200" Background="PowderBlue"
IsSnapToTickEnabled="True"
Minimum="150" Maximum="250"
TickPlacement="BottomRight"
TickFrequency="50"
AutoToolTipPrecision="10"
AutoToolTipPlacement="TopLeft"
IsDirectionReversed="False"
IsMoveToPointEnabled="False" />
<TextBlock Width="Auto" Text="{Binding Value, ElementName=sizeSlider}" Foreground="White" FontWeight="Bold" FontSize="14" Margin="2" Padding="0" />
</StackPanel>

How to set a ToolTip for each ListBoxItem

I have a ListBox control; how would I set the ToolTip for each ListBoxItem using the code below.
<ListBox Name="FillSelections"
VerticalContentAlignment="Stretch"
Margin="1, 3, 1, 3"
IsEnabled="True"
Grid.Column="0"
Background="Transparent"
HorizontalContentAlignment="Center"
SelectedItem="{Binding SelectedColor}"
SelectionMode="Single"
Style="{StaticResource HorizontalListBoxStyle}"
ItemsSource="{Binding FillColors}"
ItemTemplate="{StaticResource ColorsItemTemplate}">
</ListBox>
<DataTemplate x:Key="ColorsItemTemplate">
<Border Width="20"
Height="16"
BorderBrush="Black"
BorderThickness="1">
<Border.Background>
<SolidColorBrush Color="{Binding}" />
</Border.Background>
<Path Stroke="Red"
StrokeThickness="3"
x:Name="abc"
Visibility="Hidden">
<Path.Data>
<LineGeometry StartPoint="0,16" EndPoint="20,0"/>
</Path.Data>
</Path>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding}" Value="#00FFFFFF">
<Setter TargetName="abc" Property="Visibility" Value="Visible"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
Try something like this
<ListBox Width="400" Margin="10"
ItemsSource="{Binding Source={StaticResource myTodoList}}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=TaskName}"
ToolTipService.ToolTip="{Binding Path=TheTooltipText}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Of course adapt the ItemsSource binding with whatever your binding source is, and the binding Path parts with whatever public property of the objects in the list you actually want to display.
You could create a style for ListBoxItem. So something along the lines of:
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style TargetType="ListBoxItem">
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip>
<TextBlock>Hello</TextBlock>
</ToolTip>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<ListBox>
<ListBoxItem>
<TextBlock Text="Hello" />
</ListBoxItem>
</ListBox>
</Grid>
</Window>

How to make usercontrol take whole space of the region its injected into

I have a view which is injected into an region (Itemscontrol). The view only takes up space in the region depending on content size. I want that the view streches for whole height of the region. Here is code of my view:
<UserControl x:Name="userControl" x:Class="DishPromo.Modules.Payments.SideCart.SideCartView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:infUIFramework="clr-namespace:DishPromo.Infrastructure.UIFramework;assembly=DishPromo.Infrastructure"
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:Convert="clr-namespace:DishPromo.Modules.Payments.SideCart"
mc:Ignorable="d" >
<UserControl.Resources>
<Convert:ObjectToStringConverter x:Key="ToString" />
<Convert:BooleanToVisibilityConverter x:Key="ToVisibility" />
<Convert:WOMsgVisibilityConverter x:Key="WOMsgVisibility" />
<Convert:WorkOrderMsgConverter x:Key="WorkOrderMsg" />
<Convert:RescheduleValueConverter x:Key="ValueConverter" />
<Convert:PaymentAmountDueNow x:Key="PaymentAmountDueNow" />
<Style TargetType="Button" x:Key="hotkeyStyle">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="25"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<Border Name="border"
Padding="4,2" CornerRadius="3"
BorderBrush="DarkGray"
/>
<Rectangle x:Name="FVElement" Stretch="Fill" StrokeLineJoin="Miter" StrokeThickness="0.5" Opacity="0" RadiusX="2" RadiusY="2"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{StaticResource {x:Static SystemColors.ControlLightLightBrushKey}}" Stroke="{StaticResource OEFlowButtonBorderStyle}"
>
</Rectangle>
<Rectangle x:Name="Background" StrokeLineJoin="Miter" StrokeThickness="0.5" Opacity="1" Margin="2" RadiusX="3" RadiusY="3">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="{StaticResource {x:Static SystemColors.ControlColorKey}}" Offset="0.576" />
<GradientStop Color="{StaticResource {x:Static SystemColors.ControlLightLightColorKey}}" Offset="0" />
<GradientStop Color="{StaticResource {x:Static SystemColors.ControlColorKey}}" Offset="1" />
<GradientStop Color="{StaticResource {x:Static SystemColors.ControlLightColorKey}}" Offset="0.262" />
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,-1.85" StartPoint="0.5,1.5">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
<Path x:Name="WhiteBand" Height="4.25" Stretch="Fill" StrokeLineJoin="Miter" Fill="{StaticResource OEFlowButtonWhiteBandFillStyle}"
Data="M4.2160064,2.75 C4.2160064,1.6454305 5.1114369,1.7153466 6.2160064,1.7153466 L22.679308,1.7153466 C23.783877,1.7153466 24.679308,1.6454305 24.679308,2.75 24.679308,2.75 4.2160064,2.75 4.2160064,2.75 z"
Margin="7,4,7,0" HorizontalAlignment="Center" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontWeight="Light"
TextWrapping="WrapWithOverflow" Text="{TemplateBinding Content}" x:Name="btnName" >
</TextBlock>
<ContentPresenter />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="#FF585151" />
<Setter Property="Cursor" Value="Hand" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" >
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="#FF219921" Offset="0.35"/>
<GradientStop Color="#FF216B99" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="RenderTransform" >
<Setter.Value>
<TranslateTransform Y="0.5" />
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="border" Property="Opacity" Value="0.3" />
<Setter TargetName="Background" Property="Opacity" Value="0.3" />
<Setter TargetName="FVElement" Property="Opacity" Value="0.3" />
<Setter TargetName="btnName" Property="Foreground" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<DockPanel VerticalAlignment="Stretch" LastChildFill="True" >
<DockPanel.InputBindings>
<KeyBinding Command="{Binding MinPaymentOverride}" Gesture="SHIFT+CTRL+y"></KeyBinding>
<KeyBinding Command="{Binding PIAMinPaymentOverride}" Gesture="SHIFT+CTRL+m"></KeyBinding>
<KeyBinding Command="{Binding EFTOverride}" Gesture="SHIFT+CTRL+e"></KeyBinding>
<KeyBinding Command="{Binding CCOverride}" Gesture="SHIFT+CTRL+c"></KeyBinding>
<KeyBinding Command="{Binding OverrideCC}" Gesture="SHIFT+CTRL+c"></KeyBinding>
<KeyBinding Command="{Binding OverrideSSN}" Gesture="SHIFT+CTRL+s"></KeyBinding>
<KeyBinding Command="{Binding OverrideCertificate}" Gesture="SHIFT+CTRL+j"></KeyBinding>
<KeyBinding Command="{Binding OverrideSellingAgent}" Gesture="SHIFT+CTRL+d"></KeyBinding>
<KeyBinding Command="{Binding OverrideRefCompany}" Gesture="SHIFT+CTRL+i"></KeyBinding>
<KeyBinding Command="{Binding OverrideSellingCompany}" Gesture="SHIFT+CTRL+n"></KeyBinding>
</DockPanel.InputBindings>
<DockPanel.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ChangeFocus}" Value="True">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=SidecartRemove}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DockPanel.Style>
<!--<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>-->
<DockPanel x:Name="dpNotificationArea" Margin="0" VerticalAlignment="Bottom" AllowDrop="True" LastChildFill="True" >
<!--<Grid.RowDefinitions>
<RowDefinition MinHeight="350" />
<RowDefinition Height="29"/>
<RowDefinition Height="58"/>
<RowDefinition Height="27"/>
</Grid.RowDefinitions>-->
<Grid Grid.Row="3" VerticalAlignment="Bottom" DockPanel.Dock="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="260"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Width="Auto" FontWeight="Bold" Foreground="Red">
<MultiBinding Converter="{StaticResource PaymentAmountDueNow}">
<Binding Path="CustomerModel.AccountInfo.Pricer.PaymentRequired"/>
<Binding Path="CustomerModel.AccountInfo.AccountStatus"/>
</MultiBinding>
</Label>
<StackPanel Grid.Column="1" x:Name="spPricerActionBar" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button Style="{StaticResource hotkeyStyle}" Width="80" x:Name="SidecartRemove" Command="{Binding RemoveCartItem}"
IsEnabled="{Binding CustomerModel.ControlStatus.RemoveIsEnabled}" GotFocus="SidecartRemove_GotFocus">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" FontWeight="Light"><Run Text="Re"/><Underline><Run Text="m"/></Underline><Run Text="ove"/></TextBlock>
</Button>
<Button x:Name="btnFeeWaived" Width="80" Content="Fees Waived" IsEnabled="{Binding IsFeeWaivedEnabled}"
Command="{Binding ShowBattery}" GotFocus="btnFeeWaived_GotFocus" />
<Button Width="100" Content="Price It" HorizontalAlignment="Right" Visibility="{Binding PriceItVisibility}" Command="{Binding GetPricing}" Background="#FF6633" Style="{StaticResource PriceItStyle}"/>
</StackPanel>
</Grid>
<StackPanel x:Name="spWorkOrder" Grid.Row="2" VerticalAlignment="Bottom" DockPanel.Dock="Bottom">
<Grid Margin="0,0,0,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="75" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<StackPanel Grid.Column="1" VerticalAlignment="Bottom">
<Button Width="70" Height="25" x:Name="btnReschedule1" Content="Reschedule" HorizontalAlignment="Right" Command="{Binding GetInstallDates}" CommandParameter="1"
Visibility="{Binding CustomerModel.AccountInfo.ScheduleInfo, ConverterParameter=1, Converter={StaticResource ToVisibility}}" />
<Button Width="70" x:Name="btnReschedule0" Content="Reschedule" HorizontalAlignment="Right" Command="{Binding GetInstallDates}" CommandParameter="0"
Visibility="{Binding CustomerModel.AccountInfo.ScheduleInfo, ConverterParameter=0, Converter={StaticResource ToVisibility}}" />
</StackPanel>
<StackPanel Grid.Column="0" VerticalAlignment="Bottom">
<Label Margin="0,5,0,5" Content="{Binding CustomerModel.AccountInfo.WorkorderInfo.DisconnectDate, Converter={StaticResource WorkOrderMsg}}"
HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Visibility="{Binding CustomerModel.AccountInfo.WorkorderInfo.DisconnectDate, ConverterParameter=0, Converter={StaticResource WOMsgVisibility}}" VerticalAlignment="Center"/>
<Label Margin="0,5,0,5" Content="{Binding CustomerModel.AccountInfo.ScheduleInfo[1], Converter={StaticResource ValueConverter}}"
HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Visibility="{Binding Visibility, ElementName=btnReschedule1}" VerticalAlignment="Center"/>
<Label Margin="0,5,0,5" Content="{Binding CustomerModel.AccountInfo.ScheduleInfo[0], Converter={StaticResource ValueConverter}}"
HorizontalAlignment="Left" FontWeight="Bold" Foreground="Blue" Visibility="{Binding Visibility, ElementName=btnReschedule0}" VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</StackPanel>
<StackPanel x:Name="NetworkQualification" Grid.Row="1" Margin="4,0,0,0" VerticalAlignment="Bottom" DockPanel.Dock="Bottom">
<TextBlock x:Name="txtbNetQualStatus" Text="{Binding CustomerModel.ServiceAddress.NetQualResult}" Foreground="Blue" FontWeight="Bold" />
<TextBlock x:Name="txtDupAddress" Text="{Binding CustomerModel.ServiceAddress.NoAddressFound}" Foreground="Blue" FontWeight="Bold"/>
</StackPanel>
<ListView Grid.Row="0" Name="lstSideCart" ScrollViewer.HorizontalScrollBarVisibility="Auto" DockPanel.Dock="Top"
ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding CustomerModel.AccountInfo.Services}" SelectionMode="Extended"
SelectionChanged="lstSideCart_SelectionChanged" MaxHeight="781" VerticalContentAlignment="Stretch" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Foreground" Value="{Binding Path=ForegroundColor}"/>
<Setter Property="FontWeight" Value="{Binding Path=FontWeight}"/>
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="DarkGray" Offset="0.0" />
<GradientStop Color="DarkGray" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0,0,0,0.5"/>
</Style>
</ListView.ItemContainerStyle>
<ListView.ContextMenu>
<ContextMenu ItemsSource="{Binding ContextMenuList}">
<ContextMenu.ItemTemplate>
<DataTemplate>
<MenuItem Header="{Binding Path=Header}" CommandParameter="{Binding}"
Click="MenuItem_Click" Visibility="{Binding Path=IsVisible}" Height="16"/>
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu>
</ListView.ContextMenu>
<ListView.View>
<GridView>
<GridViewColumn Width="175" Header="Service Code Name" DisplayMemberBinding="{Binding Description}" />
<GridViewColumn Width="100" Header="Service Type" DisplayMemberBinding="{Binding ServiceCode.SecondaryServiceTypeSingle.ServiceTypeName}"/>
<GridViewColumn Width="25" Header="#" DisplayMemberBinding="{Binding CurrentQuantity}"/>
<GridViewColumn Width="68" Header="Added" DisplayMemberBinding="{Binding Path=DateAdded, StringFormat={}{0:MM/dd/yy}}"/>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
</DockPanel>
What's the ItemsPanelTemplate of your ItemsControl?
The default is a StackPanel, which won't automatically stretch its child elements to the maximum allowed size.
You'll either have to set HorizontalAlignment to Stretch in the ItemsContainerStyle, or change the ItemsPanelTemplate to something that automatically stretches its children.
<!-- ItemContainerStyle -->
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</ItemsControl.ItemContainerStyle>
How about using a UniformGrid for your ItemsPanelTemplate like so
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
Also, StackPanels by their definition only take up space according to the content which exists, so saying something like VerticalAlignment="Stretch" won't stretch the contents of the StackPanel throughout the parent container.
Try to use a Grid as the layoutroot of your usercontrol and dont set the width and height.

Resources