XAML DynamicResource Not Working In Debug - wpf

THE PROBLEM
I have a resource in a resource dictionary called RoundCorner:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PMSpotlightSearch">
<Style x:Key="RoundCorner" TargetType="{x:Type Button}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="grid">
<Border x:Name="border" CornerRadius="20" BorderBrush="Gainsboro" BorderThickness="2">
<Border.Background>
<RadialGradientBrush GradientOrigin="0.496,1.052">
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.5" ScaleY="1.5"/>
<TranslateTransform X="0.02" Y="0.3"/>
</TransformGroup>
</RadialGradientBrush.RelativeTransform>
<GradientStop Offset="1" Color="#00000000"/>
<GradientStop Offset="0.3" Color="#FFFFFFFF"/>
</RadialGradientBrush>
</Border.Background>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" TextElement.FontWeight="Bold" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="border">
<Setter.Value>
<RadialGradientBrush GradientOrigin="0.496,1.052">
<RadialGradientBrush.RelativeTransform>
<TransformGroup>
<ScaleTransform CenterX="0.5" CenterY="0.5" ScaleX="1.5" ScaleY="1.5"/>
<TranslateTransform X="0.02" Y="0.3"/>
</TransformGroup>
</RadialGradientBrush.RelativeTransform>
<GradientStop Color="#00000000" Offset="1"/>
<GradientStop Color="#FF303030" Offset="0.3"/>
</RadialGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="border" Value="#FF33962B"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="grid" Value="0.25"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
I have loaded it into App.xaml:
<Application x:Class="PMSpotlightSearch.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PMSpotlightSearch"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="RoundedCornerButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
And it appears to work in my UserControl:
<UserControl x:Class="PMSpotlightSearch.SunkenButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Border Width="75" Height="40" BorderThickness="1">
<Button Name="btnMain" Height="30" Width="73" Content="{Binding Name}" Visibility="Visible" FontSize="12" Foreground="LightGray"
Click="Button_Click" Background="#FF292929" Style="{DynamicResource RoundCorner}">
</Button>
</Border>
</UserControl>
This produces no errors, and shows up in the preview:
Beautiful, right? Here's how it looks in Debug mode:
Like a typical button...
Any suggestions?

The solution is to add the ResourceDictionary directly to the UserControl. Adding it to App.xaml is NOT enough:
<UserControl x:Class="PMSpotlightSearch.GLButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="RoundCorner.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Border Width="50" Height="50" BorderThickness="1">
<Button Name="btnMain" Height="40" Width="40" Content="{Binding Name}" Visibility="Visible" FontSize="12" Foreground="LightGray"
Click="Button_Click" Background="#FF292929" Style="{DynamicResource RoundCorner}" />
</Border>
</UserControl>

Related

Problem with icon in TabHeader - Icon path is correct but icon will not load

I need to show Icons in the tabitem header.
The challenge is to load the text and the icon path from the "Window.Resource"
Every tab item should use the same style resource and load the assigned array data.
My Problem is, the picture for the path will not load.
Where is my error or what I have to do in an other way?
<Window x:Class="Wpf_TabItem_Image.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="CanResizeWithGrip"
UseLayoutRounding="True">
<Window.Resources>
<SolidColorBrush x:Key="Color_red" Color="Red" />
<SolidColorBrush x:Key="Color_white" Color="White" />
<SolidColorBrush x:Key="Color_black" Color="Black" />
<SolidColorBrush x:Key="Color_darkgrey" Color="DarkGray" />
<Style x:Key="TabControl_reference" TargetType="{x:Type TabControl}">
<Setter Property="TabStripPlacement" Value="Top" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TabPanel Grid.Row="0"
Grid.Column="0"
Margin="0"
Panel.ZIndex="0"
IsItemsHost="True"
Background="{StaticResource Color_white}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabItem_reference" TargetType="TabItem">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid>
<Border x:Name="TabItemBorder" CornerRadius="0" BorderThickness="0" BorderBrush="Transparent">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Left" ContentSource="Header" />
</Border>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,10,0">
<Image Source="{Binding [4]}" /> <!-- Why isn't the image shown? -->
<Image Source="{Binding [3]}" /> <!-- Why isn't the image shown? -->
<Image Source="{Binding [1]}" /> <!-- Why isn't the image shown? -->
<Image Source="{Binding [0]}" /> <!-- Why isn't the image shown? -->
<TextBlock Text="{Binding [2]}"/> <!-- But text is shown... -->
</StackPanel>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{StaticResource Color_red}"/>
<Setter TargetName="TabItemBorder" Property="Background" Value="{StaticResource Color_black}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{StaticResource Color_white}" />
<Setter TargetName="TabItemBorder" Property="Background" Value="{StaticResource Color_red}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<x:Array x:Key="TabItemHeaderContext" Type="{x:Type sys:String}">
<sys:String>/Image/info_red_48dp.png</sys:String>
<sys:String>~\..\Image\info_red_48dp.png</sys:String>
<sys:String>[ ? ] ReferencedText</sys:String>
<sys:String>/Wpf_TabItem_Image;component/Image/info_red_48dp.png</sys:String>
<sys:String>pack://application:,,,/Wpf_TabItem_Image;component/Image/info_red_48dp.png</sys:String>
</x:Array>
<x:Array x:Key="TabItemHeaderContext2" Type="{x:Type sys:String}">
<sys:String>/Image/hub_red_48dp.png</sys:String>
<sys:String>~\..\Image\hub_red_48dp.png</sys:String>
<sys:String>[ ? ] AnOtherReferencedText</sys:String>
<sys:String>/Wpf_TabItem_Image;component/Image/hub_red_48dp.png</sys:String>
<sys:String>pack://application:,,,/Wpf_TabItem_Image;component/Image/hub_red_48dp.png</sys:String>
</x:Array>
</Window.Resources>
<Grid>
<TabControl Style="{StaticResource TabControl_reference}">
<TabItem Header="No Reference" />
<TabItem Style="{StaticResource TabItem_reference}" DataContext="{StaticResource TabItemHeaderContext}">
<Grid>
</Grid>
</TabItem>
<TabItem Style="{StaticResource TabItem_reference}" DataContext="{StaticResource TabItemHeaderContext2}" >
<Grid>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>

Why my styles gone when set user button control content in WPF?

please apologize me for my weakness in English.
I'm new to WPF , And i have a issue here as question title.
I tried to Implement a WPF User Control as button. but when i want to use the button on my app. i got error. here is my code & error.
User Control XAML Code :
<UserControl x:Class="AADControls.Buttons.Warning"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:AADControls.Buttons"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<LinearGradientBrush x:Key="aad-warning-back-brush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0" Color="#FFF0F200"/>
<GradientStop Offset="1" Color="#FFFF8800"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="aad-warning-border-brush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0" Color="#FFF0F200"/>
<GradientStop Offset="1" Color="#FFFF8800"/>
</LinearGradientBrush>
</UserControl.Resources>
<Button Name="BtnWarning" Width="250" Height="50"
Content="AAD Button">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="AADBorder"
CornerRadius="10"
BorderThickness="4"
BorderBrush="{StaticResource aad-warning-border-brush}"
Background="{StaticResource aad-warning-back-brush}">
<ContentPresenter Content="{TemplateBinding Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.0" ScaleY="1.0"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseCaptured" Value="true">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Opacity="0.8" Direction="135"
ShadowDepth="3" BlurRadius="1" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</UserControl>
My Usage of User Control :
<Window x:Class="DepaSOS.Pages.wndInitialize"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:AAD="clr-namespace:AADControls.Buttons;assembly=AADControls"
xmlns:local="clr-namespace:DepaSOS.Pages"
mc:Ignorable="d"
Title="launch-n-Initialization"
WindowStartupLocation="{StaticResource WSL}">
<AAD:Warning Grid.Row="11" Grid.ColumnSpan="3"/>
Now the problem is Until i Use
<AAD:Warning Grid.Row="11" Grid.ColumnSpan="3"/>
Every thing is ok and the content shown is a default content, which set in the user control.The appearance of my control is like this Image :
But, If i just add Content Property to my button like this
<AAD:Warning Grid.Row="11" Grid.ColumnSpan="3" Content="Bla Bla Bla"/>
, every things about style goes wrong like this Image :
The XAML inside the <UserControl>...</UserControl> element is the Content of the UserControl. By default, it contains a Button. You are replacing the button with text, so you see the text instead of the button. You aren't losing the button's style. You're losing the whole button.
You are doing nothing that could possibly place the Content of the usercontrol inside a button. If you want to do that, you want to set the UserControl's template: The template determines how the content is presented (your own button template demonstrates just that). Like this:
<UserControl
x:Class="AADControls.Buttons.Warning"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:AADControls.Buttons"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Content="AAD Button"
>
<UserControl.Resources>
<LinearGradientBrush x:Key="aad-warning-back-brush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0" Color="#FFF0F200"/>
<GradientStop Offset="1" Color="#FFFF8800"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="aad-warning-border-brush" StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0" Color="#FFF0F200"/>
<GradientStop Offset="1" Color="#FFFF8800"/>
</LinearGradientBrush>
</UserControl.Resources>
<!-- This template contains the XAML you had for the Content. -->
<UserControl.Template>
<ControlTemplate TargetType="UserControl">
<Button
Name="BtnWarning"
Width="250"
Height="50"
Content="{TemplateBinding Content}"
>
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border
Name="AADBorder"
CornerRadius="10"
BorderThickness="4"
BorderBrush="{StaticResource aad-warning-border-brush}"
Background="{StaticResource aad-warning-back-brush}"
>
<ContentPresenter
Content="{TemplateBinding Content}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.0" ScaleY="1.0"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseCaptured" Value="true">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect
Opacity="0.8"
Direction="135"
ShadowDepth="3"
BlurRadius="1" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</ControlTemplate>
</UserControl.Template>
</UserControl>
Notice a few things:
The XAML you had for the content is now all in the UserControl's ControlTemplate
The Content of the Button is now Content="{TemplateBinding Content}". That means, "Find the Content property of the control the template is applied to, and use its value here."
We are now setting the Content property of the UserControl to "AAD Button" -- the text you formerly were assigning to the button's content.
Content="AAD Button"
That will be the default content of the usercontrol, which will be displayed in the button unless you give it some different content. Here, for example, you're giving it the content "Bla Bla Bla", which will be displayed in the button.
<AAD:Warning Grid.Row="11" Grid.ColumnSpan="3" Content="Bla Bla Bla"/>

WPF Mouse Hover

could you please help me if there is anyway to make button hover and click image change? Here is my current code:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="MOP_Launcher" mc:Ignorable="d" x:Class="MainWindow"
Title="MOP Launcher" Height="523" Width="977" WindowStyle="None" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Cursor="Arrow" Icon="pack://siteoforigin:,,,/mop.png" Foreground="{x:Null}" Visibility="Visible" AllowsTransparency="True">
<Window.Background>
<ImageBrush ImageSource="pack://siteoforigin:,,,/MOP Launcher BG.png"/>
</Window.Background>
<Grid>
<Button x:Name="playbtn" Content="Button" HorizontalAlignment="Left" Height="91" Margin="779,422,0,0" VerticalAlignment="Top" Width="165" Foreground="{x:Null}" BorderBrush="{x:Null}" Template="{DynamicResource ButtonControlTemplate2}" >
<Button.Background>
<ImageBrush ImageSource="play.png"/>
</Button.Background>
</Button>
</Grid>
You can use button style to change the imagebrush as below:
<Button>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="play.png"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseCaptureWithin" Value="true">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="pause.png"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
Thanks

WindowsFormsHost not showing when Wpf Window style is set

I have a WPF Window that has a WinForms Button inside. When I set the Style of the Window the button isn't rendered, but when the Window Style is not set the Button appears as it should be.
Window Xaml:
<Window x:Class="Telbit.TeStudio.View.Forms.FloatingTestComponentsBrowser"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="Test Components Browser" Style="{DynamicResource TSHUD}"
SizeToContent="WidthAndHeight" Closing="Window_Closing" >
<Grid Name="windowContent" Height="300" Width="300">
<WindowsFormsHost HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<wf:Button Text="Try" Name="btnTry" MaximumSize="100,25" BackColor="LightGray"/>
</WindowsFormsHost>
</Grid>
</Window>
Here is the Style for the window:
<Style x:Key="TSHUD" TargetType="{x:Type Window}">
<Setter Property="ShowInTaskbar" Value="False"/>
<Setter Property="BorderThickness" Value="0px"/>
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Grid x:Name="LayoutRoot">
<Rectangle Fill="#ED111F29" Stroke="Black" Margin="29,29,29,29" RadiusX="3" RadiusY="3" Effect="{DynamicResource TSWindowShadow}"/>
<Rectangle Name="TSHUDHeader" Stroke="Black" Margin="29,29,29,29" VerticalAlignment="Top" Height="25" RadiusX="3" RadiusY="3">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#ED1F3A45"/>
<GradientStop Color="#EC111F29" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Name="TSHUDHeaderSplitter" Fill="#ED374551" Margin="30,54,30,29" VerticalAlignment="Top" Height="1"/>
<Label Name="TSHudTitle" Background="Transparent"
Margin="41,34,41,29" Padding="0"
HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="20" >
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}, AncestorLevel=1}, Path=Title}"
TextWrapping="Wrap" Foreground="#FF8395B1" FontWeight="Bold"/>
</Label>
<ContentPresenter/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I have other windows with the same style but only with WPF controls (some with default style and some with custom style) and there is no problem.
I've tried to Enable Visual Styles with no luck..
Thanks in advance for any help...

WPF custom shape control

I was wondering if it is possible to make a custom shape custom control.
I need to make control which contains textbox, however the control must have a shape of triangle or sth more sophisticated than regular rectangle/square.
Short answer is yes.
Long answer is reading up on WPF Control Styles:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640"
Height="480">
<Window.Resources>
<Style x:Key="TextBoxSample" TargetType="{x:Type TextBox}">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Ellipse
x:Name="Border"
Stroke="#FF393785"
StrokeThickness="2"
>
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.25,0.25" RadiusY="0.75" RadiusX="0.75">
<GradientStop Color="White" Offset="0.2"/>
<GradientStop Color="#FF2EC452" Offset="0.5"/>
<GradientStop Color="#FF606060" Offset="1"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<!-- The implementation places the Content into the ScrollViewer. It must be named PART_ContentHost for the control to function -->
<ScrollViewer
x:Name="PART_ContentHost"
Background="Transparent"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Fill" Value="#000" TargetName="Border"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<TextBox
Style="{StaticResource TextBoxSample}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="TextBox"
Width="180"
Height="180"
/>
</Grid>
</Window>

Resources