These borders appear when they are clicked or hovered and don't go until the focus is lost.
There are borders on all four sides but since it is embedded in a shorter grid, the top and bottom ones are not visible.
How to remove these borders?
Please provide an example if possible.
XAML:
<Border x:Name="SearchBorder" BorderThickness="1" HorizontalAlignment="Left" Height="40" Margin="672,34,0,0" VerticalAlignment="Top" Width="355" Background="#3F000000">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#4C000000" Offset="0"/>
<GradientStop Color="#3FFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<TextBox x:Name="SearchBox" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
<TextBlock HorizontalAlignment="Left" Height="23" Margin="320,0,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Center" Width="21" FontFamily="FontAwesome" FontSize="25" Foreground="#FF919191"/>
<Rectangle HorizontalAlignment="Left" Margin="311,-2,0,0" Width="1">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#3F404040" Offset="0"/>
<GradientStop Color="#3F686868" Offset="1"/>
<GradientStop Color="#59DADADA" Offset="0.502"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
</Grid>
</Border>
Try BorderThickness="0"
<TextBox x:Name="SearchBox" BorderThickness="0" HorizontalAlignment="Left" Height="40" Width="296" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Center" SelectionBrush="Black" Background="#00000000" Foreground="#FF5B5B5B" FontSize="25" FontFamily="Segoe UI Light" BorderBrush="#00000000" CaretBrush="#FF6C6C6C"/>
you can remove the border by just setting the BorderBrush property to Transparent.
Normal View: Set the BorderBrush property to "Transparent"
<Button Name="BtnTest"
Content="Test"
BorderBrush="Transparent"
Height="20"
Width="75"/>
Hovering View: While you are hovering the control with mouse, Include these Control Template for Button or any control like Textbox or Textblock etc.. under the Window.Resources Tag
<Window.Resources>
<Style TargetType="Button">
<!--Default Values-->
<Setter Property="BorderBrush"
Value="Transparent"/>
<!--Transparent Highlight-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
Related
Using the gong drag and drop framework, one gets a drag effect, which is a simple border around the possible droptarget.
However, in my case for some reason this border doesn't fit the actual element, as shown here:
I have already tried to change background colors of the different xaml elements of the drop target to find out if some elements are bigger (but hidden), but couldn't find any.
I guess the problem is due to the usage of viewboxes, which I use, since the size of these drop targets is dynamic and zoom-able.
Here is the xaml code of drop target:
<Border BorderThickness="{Binding PlatformBorderThickness}" dd:DragDrop.IsDropTarget="True" dd:DragDrop.DropHandler="{StaticResource CustomDropHandler}" >
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0" >
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="Black" Offset="0.1"/>
<GradientStop Color="Transparent" Offset="0.1"/>
<GradientStop Color="Transparent" Offset="0.9"/>
<GradientStop Color="Black" Offset="0.9"/>
<GradientStop Color="Black" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Viewbox Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" HorizontalAlignment="Left">
<TextBlock Text="{Binding Equipment.Name, FallbackValue='Please add a device!'}" FontWeight="Bold"/>
</Viewbox>
<Viewbox Grid.Column="1" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" Stretch="Uniform" HorizontalAlignment="Right">
<Button Command="{Binding DeleteButtonClick}" Background="Transparent" BorderThickness="0"
Margin="0" Padding="0">
<Image Source="/Resources/Cancel.ico"/>
</Button>
</Viewbox>
<Viewbox Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="1" Grid.RowSpan="1" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" Margin="2">
<DataGrid Width="200" Height="135" HeadersVisibility="None" RowBackground="Transparent" BorderThickness="0"
ItemsSource="{Binding Equipment.Settings}" SelectionMode="Single" AutoGenerateColumns="False" GridLinesVisibility="Vertical" CanUserAddRows="False"
GotFocus="DataGrid_GotFocus" Name="DutInfoGrid" >
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
</DataGrid.Resources>
<DataGrid.Background>
<ImageBrush ImageSource="{Binding Equipment.ImagePath, FallbackValue={StaticResource AddItemImage}, TargetNullValue={StaticResource AddItemImage}}"
Stretch="Fill" Opacity="0.25"/>
</DataGrid.Background>
<DataGrid.Columns>
<DataGridTemplateColumn >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="DutInfoGridRemoveButton" Background="Transparent" BorderThickness="0" Margin="0" Padding="0" Height="15"
Command="{Binding Path=DataContext.RemoveClick, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding}">
<Image Source="/Resources/Trash.ico"/>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Items[3].Value}"/>
<DataGridTextColumn Binding="{Binding Items[6].Value}" />
</DataGrid.Columns>
</DataGrid>
</Viewbox>
</Grid>
</Border>
Edit:
After some further testing I found out that if I remove the ViewBox element around the datagrid, the problem is gone. Any ideas, why the ViewBox causes this issue and how to solve it?
You should probably switch to the action file, then swap and use jQuery with the XML code which will refer to the drag and drop.
Good Evening Guys, I am new to WPF application. I have a trouble with Indeterminate progress bar design. I had researched a lot of progress bar related topic via online but I still not clear about the progress bar styling concept.
I had tried on changing the value of corner radius and set true for clip to bounds on every possible element that affected the corner radius (PART_Indicator,PART_Track,Indicator,Animation), but still no luck with this.
The Child Border always overlap it's parent. Shown as below
What I want to achieve on Progress bar shown as below.
Below is my code:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="150">
<Grid>
<StackPanel Orientation="Vertical">
<ProgressBar Height="36" Name="progBar" VerticalAlignment="Top" IsIndeterminate="True" Foreground="Orange" BorderBrush="Gray" BorderThickness="1" >
<ProgressBar.Style>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar" >
<Grid Name="TemplateRoot" SnapsToDevicePixels="True">
<Rectangle RadiusX="2" RadiusY="2" Fill="Transparent" />
<Border CornerRadius="10" Margin="1,1,1,1">
<Border.Background>
<SolidColorBrush Color="Transparent"/>
</Border.Background>
</Border>
<Border BorderThickness="1" BorderBrush="gray" Margin="1,1,1,1" CornerRadius="10">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="White" Offset="0.0" />
<GradientStop Color="WhiteSmoke" Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Rectangle Name="PART_Track" Margin="1,1,1,1" ClipToBounds="True"/>
<Decorator Name="PART_Indicator" Margin="3,2,3,2" HorizontalAlignment="Left" ClipToBounds="True">
<Grid Name="Foreground" ClipToBounds="True">
<Rectangle RadiusX="10" RadiusY="10" Name="Indicator" ClipToBounds="True"/>
<Grid Name="Animation" ClipToBounds="True">
<Border Name="PART_GlowRect" Width="50" Margin="1" HorizontalAlignment="Left" Background="Orange" CornerRadius="10" />
</Grid>
<Grid Name="Overlay">
</Grid>
</Grid>
</Decorator>
<Border BorderThickness="0" CornerRadius="0" BorderBrush="Transparent" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ProgressBar.Style>
</ProgressBar>
</StackPanel>
</Grid>
</Window>
What had I did wrong on the code? Please for guide me regarding this issue.
Thank you.
Check out Clip property:
<Image
Source="sampleImages\Waterlilies.jpg"
Width="200" Height="150" HorizontalAlignment="Left">
<Image.Clip>
<EllipseGeometry
RadiusX="100"
RadiusY="75"
Center="100,75"/>
</Image.Clip>
</Image>
You can put any geometry inside Clip property. In your case it can be RectangleGeometry with RadiusX and RadiusY properties set.
More info: https://msdn.microsoft.com/ru-ru/library/system.windows.uielement.clip(v=vs.110).aspx
Thanks for Mikolaytis's answer, I am currently using RectangleGeometry.
I believe the Rect in RectangleGeometry it will not inherit the width from the parent width, I think I need to use code behind to recalculate the rect for different resolution.
I am sharing my code below in case somone facing the same issue as I was.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="400">
<ProgressBar Height="36" Width="358" Name="progBar" VerticalAlignment="Top" IsIndeterminate="True" Foreground="Orange" BorderBrush="Gray" BorderThickness="1" >
<ProgressBar.Style>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar" >
<Grid Name="TemplateRoot" SnapsToDevicePixels="True">
<Rectangle RadiusX="2" RadiusY="2" Fill="Transparent" />
<Border CornerRadius="10" Margin="1,1,1,1">
<Border.Background>
<SolidColorBrush Color="Transparent"/>
</Border.Background>
</Border>
<Border BorderThickness="1" BorderBrush="Blue" Margin="1,1,1,1" CornerRadius="10">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="Red" Offset="0.0" />
<GradientStop Color="Red" Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Rectangle Name="PART_Track" Margin="0" ClipToBounds="True" />
<Border Background="black" Name="PART_Indicator" Margin="0" HorizontalAlignment="Left" ClipToBounds="True">
<Border.Clip>
<RectangleGeometry Rect="2,2,354,32" RadiusX="9" RadiusY="9.5" />
</Border.Clip>
<Grid Name="Foreground">
<Rectangle RadiusX="10" RadiusY="10" Name="Indicator" ClipToBounds="True"/>
<Grid Name="Animation" ClipToBounds="True">
<Border Name="PART_GlowRect" Width="50" Margin="1" HorizontalAlignment="Left" Background="Orange" CornerRadius="10" />
</Grid>
<Grid Name="Overlay">
</Grid>
</Grid>
</Border>
<Border BorderThickness="0" CornerRadius="0" BorderBrush="Transparent" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ProgressBar.Style>
</ProgressBar>
</Window>
I want to change only the color inside the radio button when clicked. I mean the tiny dot inside the circle.
How in WPF can i do this?
I tried this code but it is saying the content is set more than once
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<StackPanel Orientation="Horizontal">
<Grid Width="40" Height="40">
<Ellipse Name="MainEllipse" Width="40" Height="40">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFC8C8C8" Offset="0" />
<GradientStop Color="#FFF7F7F7" Offset="0.991" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Margin="10,10,10,10"
Fill="#C0C0C0"
Width="Auto"
Height="Auto" />
<Ellipse x:Name="Selected"
Margin="10,10,10,10"
Width="Auto"
Height="Auto">
<Ellipse.Fill>
<SolidColorBrush Color="Navy" />
</Ellipse.Fill>
</Ellipse>
</Grid>
<ContentPresenter Margin="5,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</BulletDecorator.Bullet>
</BulletDecorator>
Thanks in advance,
John.
Move your ContentPresenter outside of your StackPanel. Actually, you don't appear to need the StackPanel at all:
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<Grid Width="40" Height="40">
<Ellipse Name="MainEllipse" Width="40" Height="40">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFC8C8C8" Offset="0" />
<GradientStop Color="#FFF7F7F7" Offset="0.991" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse Margin="10,10,10,10"
Fill="#C0C0C0"
Width="Auto"
Height="Auto" />
<Ellipse x:Name="Selected"
Margin="10,10,10,10"
Width="Auto"
Height="Auto">
<Ellipse.Fill>
<SolidColorBrush Color="Navy" />
</Ellipse.Fill>
</Ellipse>
</Grid>
</BulletDecorator.Bullet>
<ContentPresenter Margin="5,0,0,0" VerticalAlignment="Center" />
</BulletDecorator>
This page might help you: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/35639a99-b2b2-4fe9-955d-775cb88ead43
It involves setting up a custom style for RadioButton.
Hi there i am new to WPF.I have applied round corner text box by using
<Window.Resources>
saw on some website do not know if it is best.
Now i may have 4 text boxes all having round corners
I have selected a border brush color and want that it should change when ever the some particular textbox has focus.so i added event
private void textBox1_GotFocus(object sender, RoutedEventArgs e)
{
textBoxCpanelUserName.BorderBrush = Brushes.OrangeRed;
}
but no effect.I checked when text box has focus the event fires but never changes the value of border brush.
Following is my XMAL
<Window x:Class="AutomatingSomething.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="800" Name="MainContainer" xmlns:my="clr-namespace:WPFControls.Clocks;assembly=WPFControls" xmlns:common="clr-namespace:WPF.Common">
<Window.Resources>
<ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}">
<Border Background="{TemplateBinding Background}"
x:Name="Bd" BorderBrush="#FF3BB5C8"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="7">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Width" Value="Auto">
<Setter Property="MinWidth" Value="100"/>
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="20"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<Grid Name="MasterGrid">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF484848" Offset="0.075" />
<GradientStop Color="#FF8A8A8A" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Border BorderBrush="Silver" BorderThickness="0" Height="45" HorizontalAlignment="Left" Margin="902,12,0,0" Name="border1" VerticalAlignment="Top" Width="88">
<my:RetroClock Name="retroClock1" FontSize="28" FontWeight="Normal" />
</Border>
<Button Content="Button" Name="button1" Margin="12,25,907,608" Click="button1_Click" />
<Grid common:VisibilityAnimation.AnimationType="Fade" Height="524" HorizontalAlignment="Left" Margin="101,25,0,0" Name="CpanelSettings" VerticalAlignment="Top" Width="665">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFD4D4D4" Offset="0" />
<GradientStop Color="#FF797979" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Label Content="Cpanel Settings" Height="38" HorizontalAlignment="Left" Margin="289,6,0,0" Name="label1" VerticalAlignment="Top" FontWeight="Bold" FontSize="26" FontFamily="Tekton Pro" FontStretch="Condensed" Width="147">
<Label.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="#FFB4AFAF" Offset="1" />
</LinearGradientBrush>
</Label.Foreground>
</Label>
<TextBox Height="30" HorizontalAlignment="Left" Margin="132,50,0,0" Name="textBoxCpanelUserName" VerticalAlignment="Top" Width="187" FontFamily="Tekton Pro" FontWeight="Bold" BorderThickness="2" Template="{StaticResource TextBoxBaseControlTemplate}" FontSize="15" BorderBrush="#FF3BB5C8" GotFocus="textBox1_GotFocus" />
<Label Content="Cpanel Settings" FontFamily="Tekton Pro" FontSize="20" FontStretch="Condensed" FontWeight="Bold" Height="34" HorizontalAlignment="Left" Margin="6,46,0,0" Name="label2" VerticalAlignment="Top" Width="120">
<Label.Foreground>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="#FFB4AFAF" Offset="1" />
</LinearGradientBrush>
</Label.Foreground>
</Label>
</Grid>
</Grid>
</Window>
I have one more question that if i draw new textbox and try to make its corner round by the drawn template then if i change the color on one textbox on focus all get updated?(i donot want that)
I am extremely sorry if i have said any non-technical thing or said the things wrong.Its because i am totaly new to wpf
Simply add following Trigger to ControlTemplate.Triggers
<Trigger Property="IsFocused" Value="true">
<Setter Property="BorderBrush" TargetName="Bd" Value="Red"/>
</Trigger>
I suppose you forgot to bind Bd's BorderBrush in TextBoxBaseControlTemplate as you made it for Background.
Template should look like the following:
<ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}">
<Setter Property="BorderBrush" Value="#FF3BB5C8"/>
<Border Background="{TemplateBinding Background}"
x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="7">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
...
WPF Experts -
I am trying to add buttons below my custom listbox and also have the scroll bar go to the bottom of the control. Only the items should move and not the buttons. I was hoping for some guidance on the best way to achieve this. I was thinking the ItemsPanelTemplate needed to be modified but was not certain.
Thanks
My code is below
<!-- List Item Selected -->
<LinearGradientBrush x:Key="GotFocusStyle" EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Black" Offset="0.501"/>
<GradientStop Color="#FF091F34"/>
<GradientStop Color="#FF002F5C" Offset="0.5"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<!-- List Item Hover -->
<LinearGradientBrush x:Key="MouseOverFocusStyle" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF013B73" Offset="0.501"/>
<GradientStop Color="#FF091F34"/>
<GradientStop Color="#FF014A8F" Offset="0.5"/>
<GradientStop Color="#FF003363" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<!-- List Item Selected -->
<LinearGradientBrush x:Key="LostFocusStyle" EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterX="0.5" CenterY="0.5"/>
<SkewTransform CenterX="0.5" CenterY="0.5"/>
<RotateTransform CenterX="0.5" CenterY="0.5"/>
<TranslateTransform/>
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="#FF091F34" Offset="1"/>
<GradientStop Color="#FF002F5C" Offset="0.4"/>
</LinearGradientBrush>
<!-- List Item Highlight -->
<SolidColorBrush x:Key="ListItemHighlight" Color="#FFE38E27" />
<!-- List Item UnHighlight -->
<SolidColorBrush x:Key="ListItemUnHighlight" Color="#FF6FB8FD" />
<Style TargetType="ListBoxItem">
<EventSetter Event="GotFocus" Handler="ListItem_GotFocus"></EventSetter>
<EventSetter Event="LostFocus" Handler="ListItem_LostFocus"></EventSetter>
</Style>
<DataTemplate x:Key="CustomListData" DataType="{x:Type ListBoxItem}">
<Border BorderBrush="Black" BorderThickness="1" Margin="-2,0,0,-1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=ActualWidth}" />
</Grid.ColumnDefinitions>
<Label
VerticalContentAlignment="Center" BorderThickness="0" BorderBrush="Transparent"
Foreground="{StaticResource ListItemUnHighlight}"
FontSize="24"
Tag="{Binding .}"
Grid.Column="0"
MinHeight="55"
Cursor="Hand"
FontFamily="Arial"
FocusVisualStyle="{x:Null}"
KeyboardNavigation.TabNavigation="None"
Background="{StaticResource LostFocusStyle}"
MouseMove="ListItem_MouseOver"
>
<Label.ContextMenu>
<ContextMenu Name="editMenu">
<MenuItem Header="Edit"/>
</ContextMenu>
</Label.ContextMenu>
<TextBlock Text="{Binding .}" Margin="15,0,40,0" TextWrapping="Wrap"></TextBlock>
</Label>
<Image
Tag="{Binding .}"
Source="{Binding}"
Margin="260,0,0,0"
Grid.Column="1"
Stretch="None"
Width="16"
Height="22"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Grid>
</Border>
</DataTemplate>
</Window.Resources>
<Window.DataContext>
<ObjectDataProvider ObjectType="{x:Type local:ImageLoader}" MethodName="LoadImages" />
</Window.DataContext>
<ListBox ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79" >
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}">Transparent</SolidColorBrush>
<Style TargetType="{x:Type ListBox}">
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ItemTemplate" Value="{StaticResource CustomListData }" />
</Style>
</ListBox.Resources>
</ListBox>
Why don't you place the two controls (the list and the buttons panel) into a StackPanel?
<StackPanel HorizontalAlignment="Left" Margin="0,0,0,0" Width="240">
<ListBox Height="320"/>
<Button Content="buttons go here"/>
</StackPanel>
You obviously won't get the listbox's scrollbar to go to the bottom of the screen, but you could fix that by putting in a ScrollBar control.
Editing templates might yield what you want but you may simply run into a point where items at the bottom of the list could be hidden by the button panel. You could overcome this obviously by increasing the bottom padding of the last item in that list or a similar margin/padding hack.
However, I don't think sizing the scrollbar to the bottom is the best idea in terms of common sense in user interfaces as scrollbars should conventionally be placed on the side of only what is scrollable.
I know I'm joing the party rather late, but you should be able to accomplish this by applying a custom ScrollViewier control template to be used by the ListBox. I have not tested this, but it should work (or at least offer a starting point):
<ListBox ...>
<ListBox.Resources>
<Style TargetType="ScrollViewer">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Items Go Here -->
<ScrollContentPresenter Grid.Column="0" />
<!-- Buttons Go Here -->
<Grid Grid.Column="0"
Grid.Row="1"
>
...
</Grid>
<!-- ScrollBar spans all three rows but should only affect the presenter -->
<ScrollBar x:Name="PART_VerticalScrollBar"
Grid.Column="1"
Grid.Row="0"
Grid.RowSpan="3"
Value="{TemplateBinding VerticalOffset}"
Maximum="{TemplateBinding ScrollableHeight}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
/>
<ScrollBar x:Name="PART_HorizontalScrollBar"
Grid.Column="0"
Grid.Row="1"
Orientation="Horizontal"
Value="{TemplateBinding HorizontalOffset}"
Maximum="{TemplateBinding ScrollableWidth}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.Resources>
</ListBox>