Click here to Skip to main content
15,886,919 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 4:14
mveRichard Deeming28-Oct-14 4:14 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 7:34
mveRichard Deeming28-Oct-14 7:34 
GeneralRe: DataTransferManager RT Only? Pin
Richard Deeming28-Oct-14 8:42
mveRichard Deeming28-Oct-14 8:42 
QuestionWPF MVVM VALIDATION Pin
Arun Karuvatta23-Oct-14 22:08
professionalArun Karuvatta23-Oct-14 22:08 
AnswerRe: WPF MVVM VALIDATION Pin
Pete O'Hanlon23-Oct-14 22:42
mvePete O'Hanlon23-Oct-14 22:42 
QuestionWPF or MVC 4 Problem? Pin
Kevin Marois18-Oct-14 17:38
professionalKevin Marois18-Oct-14 17:38 
AnswerRe: WPF or MVC 4 Problem? Pin
Richard Deeming20-Oct-14 1:51
mveRichard Deeming20-Oct-14 1:51 
RantWPF - Why? Pin
SteveHolle17-Oct-14 6:20
SteveHolle17-Oct-14 6:20 
I'm working through the excellent book "Windows Presentation Foundation 4.5 Cookbook" by Pavel Yosifovich, trying to broaden my skill set. I'm at the 70% mark according to my Kindle Reader and still asking "why?" I don't normally like to copy the downloaded code because I learn a great deal by typing the code in and troubleshooting my errors. I finally threw in the towel with the code I will insert at the end of this post. My main aggravation is trying to use XAML to design graphical interfaces. I find it impossible to picture in my head anything but the simplest constructs. This may be a deficiency on my part but please, looking at the templates below created in App.xaml who can really tell what this is going to look like? Many lines of dense code that can't be viewed until the syntax is completely correct AND the template is used in a window.

I understand that there are tools like Blend which begs the question "Why isn't blend the default WPF design tool in Visual Studio?" Are there tools for visualizing, maybe even creating, templates?

I intend to work through the remaining chapters in this book and then explore the tools available in Blend and only use XAML to tweak. Is anyone else with me here?

Code:
<Application x:Class="CH08.CustomScrollBars.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ControlTemplate TargetType="RepeatButton" x:Key="repeatTransTemplate">
<Rectangle Fill="Transparent" />
</ControlTemplate>
<ControlTemplate TargetType="RepeatButton" x:Key="plainTemplate">
<Grid>
<ContentPresenter Margin="{TemplateBinding Padding}" />
</Grid>
</ControlTemplate>
<ControlTemplate TargetType="Thumb" x:Key="vthumbTemplate">
<Rectangle RadiusX="5" RadiusY="10" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
<ControlTemplate TargetType="ScrollBar" x:Key="verticalScrollBarTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border BorderBrush="DarkBlue" BorderThickness="1" Background="LightBlue" Grid.Row="1">
<Track x:Name="PART_Track" IsDirectionReversed="True">
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageUpCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageDownCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Template="{StaticResource vthumbTemplate}" BorderBrush="Black" BorderThickness="1">
<Thumb.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Offset="0" Color="DarkGreen" />
<GradientStop Offset="1" Color="LightGreen" />
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Border>
<Viewbox>
<RepeatButton Command="{x:Static ScrollBar.LineUpCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 25,0 L 50,50 L 0,50 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
<Viewbox Grid.Row="2">
<RepeatButton Command="{x:Static ScrollBar.LineDownCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 25,50 L 0,0 L 50,0 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
</Grid>
</ControlTemplate>
<ControlTemplate TargetType="Thumb" x:Key="hthumbTemplate">
<Rectangle RadiusX="10" RadiusY="5" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"
Fill="{TemplateBinding Background}" />
</ControlTemplate>
<ControlTemplate TargetType="ScrollBar" x:Key="horizontalScrollBarTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border BorderBrush="DarkBlue" BorderThickness="1" Background="LightBlue" Grid.Column="1">
<Track x:Name="PART_Track" IsDirectionReversed="False">
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageLeftCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageRightCommand" Template="{StaticResource repeatTransTemplate}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Template="{StaticResource hthumbTemplate}" BorderBrush="Black" BorderThickness="1">
<Thumb.Background>
<LinearGradientBrush EndPoint="1,0">
<GradientStop Offset="0" Color="DarkGreen" />
<GradientStop Offset="1" Color="LightGreen" />
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Border>
<Viewbox>
<RepeatButton Command="{x:Static ScrollBar.LineLeftCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 0,25 L 50,50 L 50,0 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
<Viewbox Grid.Column="2">
<RepeatButton Command="{x:Static ScrollBar.LineRightCommand}" Template="{StaticResource plainTemplate}">
<Path Data="M 0,0 L 50,25 L 0,50 Z" Fill="Blue" />
</RepeatButton>
</Viewbox>
</Grid>
</ControlTemplate>
<Style TargetType="ScrollBar">
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Template" Value="{StaticResource verticalScrollBarTemplate}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Template" Value="{StaticResource horizontalScrollBarTemplate}" />
</Trigger>

</Style.Triggers>
</Style>

</Application.Resources>
</Application>
GeneralRe: WPF - Why? Pin
Gerry Schmitz17-Oct-14 11:07
mveGerry Schmitz17-Oct-14 11:07 
GeneralRe: WPF - Why? Pin
RedDk17-Oct-14 11:29
RedDk17-Oct-14 11:29 
GeneralRe: WPF - Why? Pin
SteveHolle6-Nov-14 4:18
SteveHolle6-Nov-14 4:18 
GeneralRe: WPF - Why? Pin
Mycroft Holmes17-Oct-14 13:51
professionalMycroft Holmes17-Oct-14 13:51 
GeneralRe: WPF - Why? Pin
SteveHolle6-Nov-14 4:22
SteveHolle6-Nov-14 4:22 
GeneralRe: WPF - Why? Pin
Mycroft Holmes6-Nov-14 11:36
professionalMycroft Holmes6-Nov-14 11:36 
GeneralRe: WPF - Why? Pin
Gary R. Wheeler8-Nov-14 3:12
Gary R. Wheeler8-Nov-14 3:12 
GeneralRe: WPF - Why? Pin
Pete O'Hanlon11-Nov-14 20:46
mvePete O'Hanlon11-Nov-14 20:46 
QuestionProblem to synchronise two DataContext bound ComboBoxes Pin
Tom Rahav10-Oct-14 18:25
Tom Rahav10-Oct-14 18:25 
AnswerRe: Problem to synchronise two DataContext bound ComboBoxes Pin
Gerry Schmitz13-Oct-14 11:39
mveGerry Schmitz13-Oct-14 11:39 
GeneralRe: Problem to synchronise two DataContext bound ComboBoxes Pin
Tom Rahav13-Oct-14 14:39
Tom Rahav13-Oct-14 14:39 
QuestionDataGrid won't detect CTRL + C Pin
Mc_Topaz9-Oct-14 3:17
Mc_Topaz9-Oct-14 3:17 
AnswerRe: DataGrid won't detect CTRL + C Pin
Vincent Beek9-Oct-14 15:23
Vincent Beek9-Oct-14 15:23 
QuestionRe: DataGrid won't detect CTRL + C Pin
Mc_Topaz9-Oct-14 20:08
Mc_Topaz9-Oct-14 20:08 
AnswerRe: DataGrid won't detect CTRL + C Pin
Vincent Beek9-Oct-14 20:25
Vincent Beek9-Oct-14 20:25 
AnswerRe: DataGrid won't detect CTRL + C Pin
Hi I am Kevin29-Oct-14 6:05
Hi I am Kevin29-Oct-14 6:05 
QuestionViewBox Button alignment Pin
Member 102727486-Oct-14 10:00
Member 102727486-Oct-14 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.