I've removed header, footer and borders from RadDataForm:
<t:RadDataForm ItemsSource="{Binding Item}" MinHeight="300" MinWidth="300"
AutoEdit="True" BorderThickness="0" Background="Transparent"
CommandButtonsVisibility="None" BorderBrush="Transparent"
ValidationSummaryVisibility="Collapsed" />
But two lines still present. How to remove horizontal lines?
Have you ever tried to style a control by using Blend?
Note that I use Silverlight, but it should be the same.
However put this property into you RadDataForm control:
Style="{StaticResource RadDataFormStyle1}"
Now it should look like this:
<t:RadDataForm ItemsSource="{Binding Item}" MinHeight="300" MinWidth="300"
AutoEdit="True" BorderThickness="0" Background="Transparent"
CommandButtonsVisibility="None" BorderBrush="Transparent"
ValidationSummaryVisibility="Collapsed"
Style="{StaticResource RadDataFormStyleNoBorders}" />
Now you have to set a style resource. You can put the style resource into app.xaml or in the same page of the control.
For example I have an sdk:Page. For embed the Style in the same page of the control you have to do this:
<sdk:Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
xmlns:t="http://schemas.telerik.com/2008/xaml/presentation"
[other page things...]
......>
<!-- COPY FROM HERE, REPLACE ALL "telerik:" with yours "t:" and "sdk:" with your page namespace -->
<sdk:Page.Resources>
<SolidColorBrush x:Key="DataForm_HeaderOuterBorder" Color="#FF282828"/>
<SolidColorBrush x:Key="DataForm_HeaderInnerBorder" Color="#FFB5B5B5"/>
<LinearGradientBrush x:Key="DataForm_HeaderBackground" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF5B5B5B" Offset="1"/>
<GradientStop Color="#FF868686"/>
<GradientStop Color="#FF4F4F4F" Offset="0.42"/>
<GradientStop Color="#FF0E0E0E" Offset="0.43"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="DataForm_HeaderForeground" Color="White"/>
<Telerik_Windows_Controls_Data_DataForm:DescriptionVisibilityConverter x:Key="DescriptionVisibilityConverter"/>
<SolidColorBrush x:Key="DataFormPanel_Border" Color="#FF848484"/>
<LinearGradientBrush x:Key="DataForm_FooterPanel_Background" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFB5B5B5"/>
<GradientStop Color="#FFF0F0F0" Offset="0.5"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="Background_Disabled" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7F000000"/>
<GradientStop Color="#7F000000" Offset="1"/>
<GradientStop Color="#33000000" Offset="0.5"/>
</LinearGradientBrush>
<telerik:InvertedBooleanToVisibilityConverter x:Key="InvertedBooleanToVisibilityConverter"/>
<ControlTemplate x:Key="RadDataFormTemplate" TargetType="telerik:RadDataForm">
<Border x:Name="PART_RootElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="PART_DataFormGrid" Background="{TemplateBinding Background}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border x:Name="Header" BorderBrush="{StaticResource DataForm_HeaderOuterBorder}" BorderThickness="1" Margin="-1,-1,-1,0" Visibility="{Binding Header, Converter={StaticResource DescriptionVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}">
<Border BorderBrush="{StaticResource DataForm_HeaderInnerBorder}" BorderThickness="1" Background="{StaticResource DataForm_HeaderBackground}">
<ContentControl x:Name="PART_ContentPresenter" Content="{TemplateBinding Header}" Foreground="{StaticResource DataForm_HeaderForeground}" FontWeight="Bold" HorizontalContentAlignment="Stretch" Margin="4,6,4,6" VerticalAlignment="Center" VerticalContentAlignment="Top"/>
</Border>
</Border>
<Telerik_Windows_Controls_Data_DataForm:CollectionNavigator x:Name="CollectionNavigator" Grid.Row="1" telerik:StyleManager.Theme="{StaticResource Theme}" BorderBrush="{x:Null}"/>
<Border BorderThickness="0,0,0,1" Grid.Row="2">
<ScrollViewer x:Name="PART_ItemsScrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Auto" IsTabStop="False" telerik:StyleManager.Theme="{StaticResource Theme}" ScrollViewer.VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<Telerik_Windows_Controls_Data_DataForm:AutoGeneratedFieldsPresenter x:Name="PART_AutoGeneratedFieldsPresenter" AutoGenerateFields="{Binding AutoGenerateFields, RelativeSource={RelativeSource TemplatedParent}}" CurrentItem="{Binding CurrentItem}" telerik:StyleManager.Theme="{StaticResource Theme}"/>
<ContentPresenter x:Name="PART_FieldsContentPresenter" Content="{Binding CurrentItem}"/>
</StackPanel>
</ScrollViewer>
</Border>
<Telerik_Windows_Controls_Data_DataForm:DataFormValidationSummary x:Name="PART_ValidationSummary" Grid.Row="3" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{TemplateBinding ValidationSummaryVisibility}"/>
<Border x:Name="FooterPanel_Background" Background="{StaticResource DataForm_FooterPanel_Background}" Grid.Row="4">
<StackPanel x:Name="PART_FooterPanel" HorizontalAlignment="Right" Orientation="Horizontal">
<telerik:RadButton x:Name="PART_CommitButton" Content="{TemplateBinding CommitButtonContent}" Command="controls:RadDataFormCommands.CommitEdit" Margin="2,4,4,4" MinWidth="48" MinHeight="20" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding CommitButtonVisibility}"/>
<telerik:RadButton x:Name="PART_CancelButton" Content="{TemplateBinding CancelButtonContent}" Command="controls:RadDataFormCommands.CancelEdit" Margin="2,4,4,4" MinWidth="48" MinHeight="20" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding CancelButtonVisibility}"/>
</StackPanel>
</Border>
<Border x:Name="Background_Disabled" Background="{StaticResource Background_Disabled}" IsHitTestVisible="False" Grid.RowSpan="5" Visibility="{Binding IsEnabled, Converter={StaticResource InvertedBooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
</Grid>
</Border>
</ControlTemplate>
<SolidColorBrush x:Key="DataField_Foreground" Color="Black"/>
<Style x:Key="RadDataFormNoBorders" TargetType="telerik:RadDataForm">
<Setter Property="Template" Value="{StaticResource RadDataFormTemplate}"/>
<Setter Property="Foreground" Value="{StaticResource DataField_Foreground}"/>
<Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder}"/>
<Setter Property="Background" Value="{StaticResource ControlBackground}"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
</sdk:Page.Resources>
<!-- STOP COPING HERE, NOW YOU CAN PASTE, REMEMBER TO REPLACE --> ........
Alternatively you can try to use the theming property provided by Telerik:
telerik:Theming.Theme="Transparent"
this property allow you to don't style the control, but it changes the appearance of all your control, and it is possible that you don't like this theme.
Related
i'm new to WPF, I'm going to implement Gantt Chart view with respective date and Time
When i tried i can able to plot Gantt-view but not with respective date and Time, can any one help me out from this.
I want to implement the same with respective of both Time and date dynamically not static.
Thanks in advance..
Expected Gantt View is
but current implement as below:
Below is my WPF code:
<Window x:Class="FunctionalFun.UI.ItemsControlExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gc="clr-namespace:FunctionalFun.UI"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Gantt Example" Height="708" Width="1080">
<Grid>
<DataGrid AutoGenerateColumns="True" ColumnHeaderHeight="50" RowHeight="50" ColumnWidth="250" ItemsSource="{Binding}" RenderTransformOrigin="3.25,5.846" Height="526" Width="931" Canvas.Top="70" Canvas.Left="69">
</DataGrid>
<Grid Name="firstGrid" Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 1" Start="03:45" End="10:10"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Grid.Effect>
<DropShadowEffect Color="#FFDEDADA" ShadowDepth="3"/>
</Grid.Effect>
<ItemsControl Grid.Row="0" ItemsSource="{StaticResource Tasks}" Margin="100,80,0,-100">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:45" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF2FD9FD" Offset="0"/>
<GradientStop Color="#FFCAF6FF" Offset="0.112"/>
<GradientStop Color="#FF47D8F7" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 2" Start="10:10" End="22:00"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="1" ItemsSource="{StaticResource Tasks}" Margin="60,120,0,-140">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:45" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#d1b57f" Offset="0"/>
<GradientStop Color="#d1b57f" Offset="0.112"/>
<GradientStop Color="#d1b57f" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 3" Start="08:10" End="18:00"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="2" ItemsSource="{StaticResource Tasks}" Margin="60,160,0,-180">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:45" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#aa4206" Offset="0"/>
<GradientStop Color="#aa4206" Offset="0.112"/>
<GradientStop Color="#aa4206" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 4" Start="03:10" End="11:00"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="2" ItemsSource="{StaticResource Tasks}" Margin="60,200,0,-220">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:00" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#f7dd16" Offset="0"/>
<GradientStop Color="#f7dd16" Offset="0.112"/>
<GradientStop Color="#f7dd16" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 5" Start="17:10" End="23:00"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="4" ItemsSource="{StaticResource Tasks}" Margin="60,240,0,-260">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:00" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#c4ef6e" Offset="0"/>
<GradientStop Color="#c4ef6e" Offset="0.112"/>
<GradientStop Color="#c4ef6e" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 7" Start="07:10" End="17:30"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="5" ItemsSource="{StaticResource Tasks}" Margin="60,280,0,-300">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:00" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7bb507" Offset="0"/>
<GradientStop Color="#7bb507" Offset="0.112"/>
<GradientStop Color="#7bb507" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Width="Auto" Height="Auto">
<Grid.Resources>
<x:Array x:Key="Tasks" Type="{x:Type gc:Task}">
<gc:Task Name="Task 6" Start="07:10" End="17:30"/>
</x:Array>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<ItemsControl Grid.Row="7" ItemsSource="{StaticResource Tasks}" Margin="60,280,0,-300">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<gc:GanttRowPanel MinDate="03:00" MaxDate="23:00"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="gc:GanttRowPanel.StartDate" Value="{Binding Path=Start}"/>
<Setter Property="gc:GanttRowPanel.EndDate" Value="{Binding Path=End}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="#FF007F99" BorderThickness="0.1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#7bb507" Offset="0"/>
<GradientStop Color="#7bb507" Offset="0.112"/>
<GradientStop Color="#7bb507" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip="{Binding Path=Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</Window>
Update 1:
above code is only with respective date, but
I want to implement the same with respective of both Time and date dynamically not static.
I recently started learning WPF and I ran into a small problem. I am trying to create a basic button shape (Transparent) that would fit my style that I made in Photoshop.
Here is the shape (Its like a box with a triangle on each side).
http://prntscr.com/g3esel
If its easier to do it in Blend and implement it into visual then Id love to know how.
BUTTON STYLE:
<Style x:Key="Clicky" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel Orientation="Horizontal">
<Grid Height="74" Width="284" Background="{TemplateBinding Background}"/>
<TextBlock Text="{TemplateBinding Content}" TextAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Button.Opacity" Value="10" />
</Trigger>
</Style.Triggers>
</Style>
Thank you!
You need to create a ControlTemplate for the Button. This can be done both in Blend and Visual Studio. I did it in VS2015.
Here is your code:
But, for the future, try to do some work yourself before posting the question. Include just enough code to allow others to reproduce the problem. For help with this, read How to create a Minimal, Complete, and Verifiable example.
<Grid Background="Red">
<Button Height="52" Opacity="0.8">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="#053755" Offset="0" />
<GradientStop Color="#053755" Offset="0.5" />
<GradientStop Color="#061F31" Offset="0.5" />
<GradientStop Color="#061F31" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Margin="-1,0" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" Content="{TemplateBinding Content}"/>
</Border>
<Path Fill="{TemplateBinding Background}" Data="M13,0 0,25 0,27 13,52 13,52" Stroke="{TemplateBinding BorderBrush}" Width="13" Stretch="Fill" ClipToBounds="True"/>
<Path Grid.Column="2" Data="M0,0 13,25 13,27 0,52" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}" Width="13" Stretch="Fill" ClipToBounds="True"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Grid>
I'm working on a ColorPicker Control and decided it would be best to compose it of primitive Controls to be able to rearrange the various sliders and the color wheel in a control template without having to redefine everything. (Also the Controls code would become pretty messy)
I have created a new Template for the Slider Control and I want it to be scalable. For now, the size of the thumb is fixed, as is the center "Track".
<Style x:Key="ColorSlider" TargetType="{x:Type Slider}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Rectangle Grid.Column="1" Width="80" Height="480" VerticalAlignment="Center" HorizontalAlignment="Center">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="Black" Offset="1.0"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Track x:Name="PART_Track">
<Track.Thumb>
<Thumb x:Name="ValueThumb">
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Rectangle Width="100" Height="20" Fill="Transparent"/>
<Polygon Points="0,0 0,20 10,10" Fill="Black" />
<Polygon Points="100,0 100,20 90,10" Fill="Black" />
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
One way to make the control scalable would be to use a Grid however that would get messy as well since the thumb would have to extend over 3 columns and it would then be difficult to get the proportions of the thumb right.
Are there any best practices for making a control scalable? A Viewbox for example would only magnify the result and probably lower the visual quality. Are there any other methods that one could use?
UPDATE 1: To address the comments: here is an example using a Grid:
<Style x:Key="ColorSlider" TargetType="{x:Type Slider}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="5" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" MinHeight="5" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" MinWidth="10" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="1" Grid.Row="1">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="White" Offset="0.0"/>
<GradientStop Color="Black" Offset="1.0"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Track x:Name="PART_Track" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Grid.RowSpan="2">
<Track.Thumb>
<Thumb x:Name="ValueThumb">
<Thumb.Style>
<Style TargetType="Thumb">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Rectangle Height="20" Fill="Transparent"/>
<Polygon Points="0,0 0,20 10,10" Fill="Black" />
<Polygon Points="100,0 100,20 90,10" Fill="Black" />
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Thumb.Style>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
this however still won't scale the thumb triangles and there is also a visual problem for which I have no idea how it could be solved in XAML only. That is, the thumb extends over the bar to the bottom.
UPDATE 2: To make the question more specific and hopefully less "opinion based", the question can be reformulated to:
What options does one have available to make a control composed of various parts and the example above in particular scalable.
The simplest way is going to be a viewbox.
http://wpftutorial.net/ViewBox.html
I have created a TextBox control in DocumentViewer's Toolbar for displaying the current page no. and giving the user a GoTo type facility.
following is the code:
<Style x:Key="DocumentViewerStyle1" BasedOn="{x:Null}" TargetType="{x:Type DocumentViewer}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ContextMenu" Value="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerContextMenu, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DocumentViewer}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Focusable="False">
<Grid Background="{TemplateBinding Background}" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ContentControl Grid.Column="0" Focusable="{TemplateBinding Focusable}" Grid.Row="0" Style="{DynamicResource ContentControlStyle1}" TabIndex="0"/>
<ScrollViewer x:Name="PART_ContentHost" CanContentScroll="true" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalScrollBarVisibility="Auto" IsTabStop="true" Grid.Row="1" TabIndex="1"/>
<DockPanel Grid.Row="1">
<FrameworkElement DockPanel.Dock="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
<Rectangle Height="10" Visibility="Visible" VerticalAlignment="top">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#66000000" Offset="0"/>
<GradientStop Color="Transparent" Offset="1"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!--<Image Grid.Column="0" Grid.Row="2" Width="100"/>-->
</DockPanel>
<!--<TextBlock Grid.Row="2" Grid.Column="0" x:Name="txtBlock" Text="Hello World"/>-->
<ContentControl x:Name="PART_FindToolBarHost" Grid.Column="0" Focusable="{TemplateBinding Focusable}" Grid.Row="2" TabIndex="2"/>
<TextBlock Text="Aspire Education" Grid.Row="2" Grid.Column="0" Margin="300,0,0,0" Foreground="#FF0758DC" FontSize="18" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ContentControlStyle1" TargetType="{x:Type ContentControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContentControl}">
<ToolBar Focusable="{TemplateBinding Focusable}" ToolBarTray.IsLocked="True" Language="en-us" KeyboardNavigation.TabNavigation="Continue" Uid="ToolBar_2">
<Button x:Name="PrintButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerPrintButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" Command="ApplicationCommands.Print" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="0" ToolTip="Print (Ctrl+P)" Uid="Button_14" VerticalAlignment="Center" Width="24"/>
<Button x:Name="CopyButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerCopyButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" Command="ApplicationCommands.Copy" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="1" ToolTip="Copy (Ctrl+C)" Uid="Button_15" VerticalAlignment="Center" Width="24"/>
<Separator Uid="Separator_110"/>
<Button x:Name="ZoomInButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerZoomInButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" Command="NavigationCommands.IncreaseZoom" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="3" ToolTip="Increase the size of the content (Ctrl +)" Uid="Button_16" VerticalAlignment="Center" Width="24"/>
<Button x:Name="ZoomOutButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerZoomOutButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" Command="NavigationCommands.DecreaseZoom" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="4" ToolTip="Decrease the size of the content (Ctrl -)" Uid="Button_17" VerticalAlignment="Center" Width="24"/>
<Separator Uid="Separator_111"/>
<Button x:Name="ActualSizeButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerActualSizeButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" CommandParameter="100.0" Command="NavigationCommands.Zoom" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource ButtonStyle1}" ToolTipService.ShowOnDisabled="True" TabIndex="5" ToolTip="100% (Ctrl+1)" Uid="Button_18" VerticalAlignment="Center" Width="24"/>
<Button x:Name="PageWidthButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerPageWidthButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" Command="DocumentViewer.FitToWidthCommand" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="6" ToolTip="Page Width (Ctrl+2)" Uid="Button_19" VerticalAlignment="Center" Width="24"/>
<Button x:Name="WholePageButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerWholePageButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" CommandParameter="1" Command="DocumentViewer.FitToMaxPagesAcrossCommand" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="7" ToolTip="Whole Page (Ctrl+3)" Uid="Button_20" VerticalAlignment="Center" Width="24"/>
<Button x:Name="TwoPagesButton" Background="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerTwoPagesButton, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" CommandTarget="{Binding TemplatedParent, RelativeSource={RelativeSource TemplatedParent}}" CommandParameter="2" Command="DocumentViewer.FitToMaxPagesAcrossCommand" IsTabStop="True" Margin="2" Padding="2" Style="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerButtonStyle, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}" ToolTipService.ShowOnDisabled="True" TabIndex="8" ToolTip="Two Pages (Ctrl+4)" Uid="Button_21" VerticalAlignment="Center" Width="24"/>
<Separator Uid="Separator_112"/>
<TextBox x:Name="txtCurrentPage" Text="580" Width="30" BorderBrush="Black" TextChanged="txtCurrentPage_TextChanged"></TextBox>
<TextBox x:Name="txtTotalPage" Text="/250" Width="40" IsReadOnly="True" BorderBrush="Black" Foreground="Black"></TextBox>
</ToolBar>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
But when i am trying to access that textbox, it's showing null.
here is my code behind.
private void txtCurrentPage_TextChanged(object sender, TextChangedEventArgs e)
{
MainWindow mn = new MainWindow();
TextBox tb = (TextBox)mn.FindName("txtCurrentPage");
if (tb != null)
{
DocumentViewerReading.GoToPage(Convert.ToInt32(tb.Text));
}
}
Please Help
You don't need to find the control again, it's reference should be in the sender parameter.
private void txtCurrentPage_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox tb = (TextBox)sender;
if (tb != null)
{
DocumentViewerReading.GoToPage(Convert.ToInt32(tb.Text));
}
}
You were creating a new instance of a window every time the contents of the text box changes and attempting to look for a textbox within that new window, that's not quite how it should work, you've already got an instance of the window since the users are typing on it.
following is the complete solution :-
<Style x:Key="DocumentViewerStyle1" BasedOn="{x:Null}" TargetType="{x:Type DocumentViewer}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="ContextMenu" Value="{DynamicResource {ComponentResourceKey ResourceId=PUIDocumentViewerContextMenu, TypeInTargetAssembly={x:Type System_Windows_Documents:PresentationUIStyleResources}}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DocumentViewer}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Focusable="False">
<Grid x:Name="grdDocumentViewer" Background="{TemplateBinding Background}" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ContentControl Grid.Column="0" Focusable="{TemplateBinding Focusable}" Grid.Row="0" Style="{DynamicResource ContentControlStyle1}" TabIndex="0"/>
<ScrollViewer x:Name="PART_ContentHost" CanContentScroll="true" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalScrollBarVisibility="Auto" IsTabStop="true" Grid.Row="1" TabIndex="1"/>
<DockPanel Grid.Row="1">
<FrameworkElement DockPanel.Dock="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
<Rectangle Height="10" Visibility="Visible" VerticalAlignment="top">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="#66000000" Offset="0"/>
<GradientStop Color="Transparent" Offset="1"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!--<Image Grid.Column="0" Grid.Row="2" Width="100"/>-->
</DockPanel>
<!--<TextBlock Grid.Row="2" Grid.Column="0" x:Name="txtBlock" Text="Hello World"/>-->
<ContentControl x:Name="PART_FindToolBarHost" Grid.Column="0" Focusable="{TemplateBinding Focusable}" HorizontalAlignment="Right" Margin="0,0,20,0" Grid.Row="0" TabIndex="2"/>
<TextBlock x:Name="tbTopicName" Text="" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" Margin="0,2,0,0" Foreground="#FF0758DC" FontSize="20" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
//And following is the Code Behind
Grid gMain = (Grid)DocumentViewerReading.Template.FindName("grdDocumentViewer", DocumentViewerReading);
TextBlock tb = (TextBlock)gMain.FindName("tbTopicName");
tb.Text = header;
That's it.
And Thanks Andy.
so i have been trying to style a scrollviewer, so that i can change the appearance of a scroll bar. But the problem I am facing, is that when I apply the scrollviewer style to the ListBox, I never see the content anymore.
This is the current style I have: (Unchanged from the default at the moment)
<Style x:Key="CustomScrollViewerStyle" TargetType="ScrollViewer">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="VerticalScrollBarVisibility" Value="Visible"/>
<Setter Property="Padding" Value="4"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFA3AEB9" Offset="0"/>
<GradientStop Color="#FF8399A9" Offset="0.375"/>
<GradientStop Color="#FF718597" Offset="0.375"/>
<GradientStop Color="#FF617584" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ScrollViewer">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
<Grid Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ScrollContentPresenter x:Name="ScrollContentPresenter" Cursor="{TemplateBinding Cursor}" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="{TemplateBinding Padding}"/>
<Rectangle Grid.Column="1" Fill="#FFE9EEF4" Grid.Row="1"/>
<ScrollBar x:Name="VerticalScrollBar" Grid.Column="1" IsTabStop="False" Maximum="{TemplateBinding ScrollableHeight}" Margin="0,-1,-1,-1" Minimum="0" Orientation="Vertical" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{TemplateBinding VerticalOffset}" ViewportSize="{TemplateBinding ViewportHeight}" Width="18"/>
<ScrollBar x:Name="HorizontalScrollBar" Grid.Column="0" Height="18" IsTabStop="False" Maximum="{TemplateBinding ScrollableWidth}" Margin="-1,0,-1,-1" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{TemplateBinding HorizontalOffset}" ViewportSize="{TemplateBinding ViewportWidth}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And my actual ListBox xaml is:
<Grid x:Name="LayoutRoot" Background="Transparent" Height="250">
<ListBox x:Name="iListBox" DataContext="{Binding}" ItemsSource="{Binding Path=ListVM.MyCollection}"
BorderBrush="Transparent" Background="Transparent"
ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
<ListBox.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer Style="{StaticResource CustomScrollViewerStyle}"/>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate >
<DataTemplate >
<Grid Background="Transparent" Loaded="Grid_Loaded">
<IReviewerList1:MyCollectionDataItem />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Currently all I see is a scrollbar and no dataItems anymore. Was wondering what i was doing wrong? Any help would be great.
Thanks
The problem is that the ListBox doesn't know where to inject it's Items. If you insert a ItemsPresenter in the styled ScrollViewer the items should be visible again.
<ListBox.Template>
<ControlTemplate TargetType="ItemsControl">
<ScrollViewer Style="{StaticResource CustomScrollViewerStyle}">
<!-- I'm not sure if the correct name is necessary, or if
it's just for applying visual states -->
<ItemsPresenter x:Name="itemsPresenter" />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>