Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts

Tuesday, August 3, 2010

WPF Combo Box Style & Control template for combo box with rounded corners

<'LinearGradientBrush x:Key="NormalBrush" StartPoint="0,0" EndPoint="0,1"'>
<'GradientBrush.GradientStops'>
<'GradientStopCollection'>
<'GradientStop Color="#FFF" Offset="0.0"/'>
<'GradientStop Color="#CCC" Offset="1.0"/'>
<'/GradientStopCollection'>
<'/GradientBrush.GradientStops'>
<'/LinearGradientBrush'>
<'SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" /'>

<'SolidColorBrush x:Key="WindowBackgroundBrush" Color="WhiteSmoke" /'>

<'SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#DDD" /'>

<'LinearGradientBrush x:Key="NormalBorderBrush" StartPoint="0,0" EndPoint="0,1"'>
<'GradientBrush.GradientStops'>
<'GradientStopCollection'>
<'GradientStop Color="#CCC" Offset="0.0"/'>
<'GradientStop Color="#444" Offset="1.0"/'>
<'/GradientStopCollection'>
<'/GradientBrush.GradientStops'>
<'/LinearGradientBrush'>

<'SolidColorBrush x:Key="SolidBorderBrush" Color="#888" /'>
<'SolidColorBrush x:Key="GlyphBrush" Color="#444" /'>

<'ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton"'>
<'Grid'>
<'Grid.ColumnDefinitions'>
<'ColumnDefinition '/>
<'ColumnDefinition Width="20" '/>
<'/Grid.ColumnDefinitions'>
<'Border
x:Name="Border"
Grid.ColumnSpan="2"
CornerRadius="15,15,15,15"
Background="{StaticResource NormalBrush}"
BorderBrush="{StaticResource NormalBorderBrush}"
BorderThickness="1" /'>

<'Path
x:Name="Arrow"
Grid.Column="1"
Fill="{StaticResource GlyphBrush}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"/'>

<'/Grid'>

<'/ControlTemplate'>

<'ControlTemplate x:Key="ComboBoxTextBox" TargetType="TextBox"''>
<'Border x:Name="PART_ContentHost" BorderThickness="2" Focusable="False" Background="{TemplateBinding Background}" CornerRadius="10,10,10,10" /'>
<'/ControlTemplate'>

<'ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"'>
<'Grid'>
<'ToggleButton
Name="ToggleButton"
Template="{StaticResource ComboBoxToggleButton}"
Grid.Column="2"
Focusable="false"

IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press">
<'/ToggleButton'>

<'TextBox x:Name="PART_EditableTextBox"
Style="{x:Null}"
Template="{StaticResource ComboBoxTextBox}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="3,3,23,3"
Focusable="True"
Background="LightGray"
Visibility="Hidden"
IsReadOnly="{TemplateBinding IsReadOnly}"/'>

<'ContentPresenter
Name="ContentSite"
IsHitTestVisible="False"

Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="3,3,23,3"
VerticalAlignment="Center"
HorizontalAlignment="Center" /'>

<'Popup
Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Slide"'>

<'Grid
Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<'Border
x:Name="DropDownBorder"
Background="{StaticResource WindowBackgroundBrush}"
BorderThickness="1"
BorderBrush="{StaticResource SolidBorderBrush}"/'>
<'ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True"'>

<'/ScrollViewer'>
<'/Grid'>
<'/Popup'>
<'/Grid'>
<'ControlTemplate.Triggers '>
<'Trigger Property="IsMouseOver" Value="true"'>

<'/Trigger'>
<'/ControlTemplate.Triggers'>
<'/ControlTemplate'>

Creating Linear gradient brush in wpf style








TextBox Validation in WPF by giving textbox corners as red

WPF Creating Control Template - Rounded Text Box with Triggers

Monday, May 24, 2010

WPF Architecture

Presentation Framework
including large number of standard controls i.e. Button, Label, Menu, panels, and other types of controls. The vast majority of Windows Presentation Foundation developers will work exclusively with this layer.

PresentationCore.dll
includes base types, such as UIElement and Visual, from which all shapes and controls derive.

WindowsBase.dll
includes even more basic things that have the potential to be reused outside of WPF, such as DispatcherObject and DependencyObject,

Milcore.dll
is the core of the WPF rendering system and the foundation of the Media Integration Layer (MIL). Its composition engine translates visual elements into the triangle and textures that
expects. Though milcore.dll is considered a part of WPF, it’s also an essential system component for Windows Vista. The Desktop Window Manager (DWM) in Windows Vista uses milcore.dll to render the desktop.

WindowsCodecs.dll is a low-level API that provides imaging support (e.g., processing, displaying, and scaling bitmaps and JPEGs).

Direct3D

is the low-level API through which all the graphics in a WPF are rendered.

User32
is used to determine what program gets what real estate. As a result, it’s still involved in WPF, but it plays no part in rendering common controls.