VisualStateManager.GoToState with TabItem not working - wpf
My tabitem is styled by a ResourceDictionary that has a VisualState named Flashing.
I want to do something like this, but its not working.
public static void FlashTab(TabItem tbi)
{
bool thisReturnsFalse = VisualStateManager.GoToState(tbi, "Flashing", true);
}
The XAML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Color x:Key="TabBrush0">#7F605F5F</Color>
<Color x:Key="TabBrush01">#7F605F5F</Color>
<Color x:Key="TabBrush02">#7F605F5F</Color>
<Color x:Key="TabBrush03">#7F605F5F</Color>
<Color x:Key="TabBrush04">#7F605F5F</Color>
<Color x:Key="TabBrush1">#7F7E7E7E</Color>
<Color x:Key="TabBrush2">#7FFDFDFD</Color>
<Color x:Key="TabBrush3">#7FFFFFFF</Color>
<Color x:Key="TabBrush4">#BFFFFFFF</Color>
<Color x:Key="TabBrush5">#F2FFFFFF</Color>
<Color x:Key="TabBrush6">#FF6096E5</Color>
<Color x:Key="TabBrush7">#FF9B7C35</Color>
<Color x:Key="TabBrush8">#FFB0BAA1</Color>
<Color x:Key="TabBrush10">White</Color>
<Color x:Key="Foreground">#FF000000</Color>
<Color x:Key="MouseOverColor">Purple</Color>
<Color x:Key="SelectedColor">Blue</Color>
<SolidColorBrush x:Key="ForegroundBrush" Color="{DynamicResource Foreground}" />
<Style TargetType="{x:Type TabItem}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Margin="1,0,1,0" >
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="InnerRectangleMouseOver">
<EasingDoubleKeyFrame KeyTime="0" Value=".2"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="InnerRectangleSelected">
<EasingDoubleKeyFrame KeyTime="0" Value=".2"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Flashing" >
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="GlassCube"
Storyboard.TargetProperty="Opacity"
From="0.0"
To="1.0"
Duration="0:0:0.33"
AutoReverse="True"
RepeatBehavior="Forever"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="InnerRectangleMouseOver" Margin="1,1,1,1" RadiusY="5" RadiusX="5" StrokeThickness="3" Opacity="0">
<Rectangle.Effect>
<BlurEffect/>
</Rectangle.Effect>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource MouseOverColor}" Offset="0.228"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="InnerRectangleSelected" Margin="1,1,1,1" RadiusY="5" RadiusX="5" StrokeThickness="3" Opacity="0">
<Rectangle.Effect>
<BlurEffect/>
</Rectangle.Effect>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource SelectedColor}" Offset="0.228"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="InnerRectangle" Margin="1,1,1,1" RadiusY="5" RadiusX="5" StrokeThickness="3" >
<Rectangle.Effect>
<BlurEffect/>
</Rectangle.Effect>
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource Brush1}" Offset="1"/>
<GradientStop Color="{DynamicResource Brush0}"/>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource Brush13}" Offset="0.228"/>
<GradientStop Color="{DynamicResource Brush7}"/>
<GradientStop Color="{DynamicResource Brush7}" Offset="0.823"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="GlassCube" Margin="1,1,1,1" RadiusY="5" RadiusX="5" StrokeThickness="3" Opacity="1">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource Brush4}"/>
<GradientStop Color="{DynamicResource Brush4}"/>
<GradientStop Color="{DynamicResource Brush6}" Offset="0.254"/>
<GradientStop Color="{DynamicResource Brush5}" Offset="0.401"/>
</LinearGradientBrush>
</Rectangle.Stroke>
<Rectangle.OpacityMask>
<RadialGradientBrush>
<GradientStop Color="{DynamicResource Brush11}" Offset="0"/>
<GradientStop Color="{DynamicResource Brush13}" Offset="1"/>
</RadialGradientBrush>
</Rectangle.OpacityMask>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource Brush12}"/>
<GradientStop Color="{DynamicResource Brush7}" Offset="0.47"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter HorizontalAlignment="Center" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" ContentSource="Header" >
<TextBlock.Foreground>
<SolidColorBrush Color="{DynamicResource Foreground}"/>
</TextBlock.Foreground>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
The TabItem will flash when you merge the ResourceDictionary into the Window.Resources of the TabControl's parent window (the ResourceDictionary is in ResourceDictionary.xaml here):
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
and when you fix the OpacityMask of the GlassCuberectangle. I've commented it out and it happily flashes:
<Rectangle x:Name="GlassCube" Margin="1,1,1,1" RadiusY="5" RadiusX="5" StrokeThickness="3" Opacity="1">
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource TabBrush4}"/>
<GradientStop Color="{DynamicResource TabBrush4}"/>
<GradientStop Color="{DynamicResource TabBrush6}" Offset="0.254"/>
<GradientStop Color="{DynamicResource TabBrush5}" Offset="0.401"/>
</LinearGradientBrush>
</Rectangle.Stroke>
<!--<Rectangle.OpacityMask>
<RadialGradientBrush>
<GradientStop Color="{DynamicResource TabBrush11}" Offset="0"/>
<GradientStop Color="{DynamicResource TabBrush13}" Offset="1"/>
</RadialGradientBrush>
</Rectangle.OpacityMask>-->
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource TabBrush12}"/>
<GradientStop Color="{DynamicResource TabBrush7}" Offset="0.47"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
EDIT: There is one more thing to mention concerning the keys of the color resources. You define them with keys TabBrush1, TabBrush2 etc. but when you use them in Color="{DynamicResource ...}", you always use keys Brush1, Brush2 etc.
Related
How to change the colour of progressbar in WPF without loosing its style?
I want to change the colour of progress bar in WPF. When I change the colour, it loses its style. How can one change colour keeping windows default style?
Override the control template for the progress bar This generates XAML code like: <ProgressBar.Resources> <ControlTemplate x:Key="ProgressBarControlTemplate1" TargetType="{x:Type ProgressBar}"> <Grid x:Name="TemplateRoot" SnapsToDevicePixels="True"> <Rectangle Fill="{TemplateBinding Background}" RadiusY="2" RadiusX="2"/> <Border CornerRadius="2" Margin="1"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#50FFFFFF" Offset="0.5385"/> <GradientStop Color="Transparent" Offset="0.5385"/> </LinearGradientBrush> </Border.Background> </Border> <Border BorderBrush="#80FFFFFF" BorderThickness="1,0,1,1" Margin="1"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#80FFFFFF" Offset="0.05"/> <GradientStop Color="Transparent" Offset="0.25"/> </LinearGradientBrush> </Border.Background> </Border> <Rectangle x:Name="PART_Track" Margin="1"/> <Decorator x:Name="PART_Indicator" HorizontalAlignment="Left" Margin="1"> <Grid x:Name="Foreground"> <Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/> <Grid x:Name="Animation" ClipToBounds="True"> <Rectangle x:Name="PART_GlowRect" HorizontalAlignment="Left" Margin="-100,0,0,0" Width="100"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <GradientStop Color="Transparent" Offset="0"/> <GradientStop Color="#60FFFFFF" Offset="0.4"/> <GradientStop Color="#60FFFFFF" Offset="0.6"/> <GradientStop Color="Transparent" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> </Grid> <Grid x:Name="Overlay"> <Grid.ColumnDefinitions> <ColumnDefinition MaxWidth="15"/> <ColumnDefinition Width="0.1*"/> <ColumnDefinition MaxWidth="15"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Rectangle x:Name="LeftDark" Margin="1,1,0,1" RadiusY="1" RadiusX="1" Grid.RowSpan="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <GradientStop Color="#0C000000" Offset="0"/> <GradientStop Color="#20000000" Offset="0.3"/> <GradientStop Color="#00000000" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle x:Name="RightDark" Grid.Column="2" Margin="0,1,1,1" RadiusY="1" RadiusX="1" Grid.RowSpan="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1,0" StartPoint="0,0"> <GradientStop Color="#00000000" Offset="0"/> <GradientStop Color="#20000000" Offset="0.7"/> <GradientStop Color="#0C000000" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle x:Name="LeftLight" Grid.Column="0" Grid.Row="2"> <Rectangle.Fill> <RadialGradientBrush RadiusY="1" RadiusX="1"> <RadialGradientBrush.RelativeTransform> <MatrixTransform Matrix="1,0,0,1,0.5,0.5"/> </RadialGradientBrush.RelativeTransform> <GradientStop Color="#60FFFFC4" Offset="0"/> <GradientStop Color="#00FFFFC4" Offset="1"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle x:Name="CenterLight" Grid.Column="1" Grid.Row="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0,0" StartPoint="0,1"> <GradientStop Color="#60FFFFC4" Offset="0"/> <GradientStop Color="#00FFFFC4" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle x:Name="RightLight" Grid.Column="2" Grid.Row="2"> <Rectangle.Fill> <RadialGradientBrush RadiusY="1" RadiusX="1"> <RadialGradientBrush.RelativeTransform> <MatrixTransform Matrix="1,0,0,1,-0.5,0.5"/> </RadialGradientBrush.RelativeTransform> <GradientStop Color="#60FFFFC4" Offset="0"/> <GradientStop Color="#00FFFFC4" Offset="1"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Border x:Name="Highlight1" Grid.ColumnSpan="3" Grid.RowSpan="2"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#90FFFFFF" Offset="0.5385"/> <GradientStop Color="Transparent" Offset="0.5385"/> </LinearGradientBrush> </Border.Background> </Border> <Border x:Name="Highlight2" Grid.ColumnSpan="3" Grid.RowSpan="2"> <Border.Background> <LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> <GradientStop Color="#80FFFFFF" Offset="0.05"/> <GradientStop Color="Transparent" Offset="0.25"/> </LinearGradientBrush> </Border.Background> </Border> </Grid> </Grid> </Decorator> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="Orientation" Value="Vertical"> <Setter Property="LayoutTransform" TargetName="TemplateRoot"> <Setter.Value> <RotateTransform Angle="-90"/> </Setter.Value> </Setter> </Trigger> <Trigger Property="IsIndeterminate" Value="True"> <Setter Property="Visibility" TargetName="LeftDark" Value="Collapsed"/> <Setter Property="Visibility" TargetName="RightDark" Value="Collapsed"/> <Setter Property="Visibility" TargetName="LeftLight" Value="Collapsed"/> <Setter Property="Visibility" TargetName="CenterLight" Value="Collapsed"/> <Setter Property="Visibility" TargetName="RightLight" Value="Collapsed"/> <Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/> </Trigger> <!--<Trigger Property="IsIndeterminate" Value="False"> <Setter Property="Background" TargetName="Animation" Value="#80B5FFA9"/> </Trigger>--> </ControlTemplate.Triggers> </ControlTemplate> </ProgressBar.Resources> Do the changes in template in case you need to change defaults Define a data trigger and use setter to change the "foreground" property
Wpf - Using Shapes as a Resource
Iv'e got a Rectangle in my resource dictionary which i would like to place inside numerous Grid objects <Rectangle HorizontalAlignment="Left" Width="10" x:Key="ShadowRect"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1.7,0.603" StartPoint="0.3,0.603"> <GradientStop Color="White" Offset="1"/> <GradientStop Color="Black" Offset="0.009"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> Now of course i could place it directly like so : <Grid> <Rectangle HorizontalAlignment="Left" Width="10" > <Rectangle.Fill> <LinearGradientBrush EndPoint="1.7,0.603" StartPoint="0.3,0.603"> <GradientStop Color="White" Offset="1"/> <GradientStop Color="Black" Offset="0.009"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> </Grid> but i would like to use it as a Resource so i do not have to write this XAML for every Grid , how can i place the rectangle using it's resource key ?
You could have a Rectangle Style instead of a Rectangle in your ResourceDictionary: <Style x:Key="ShadowRectStyle" TargetType="Rectangle"> <Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="Width" Value="10"/> <Setter Property="Fill"> <Setter.Value> <LinearGradientBrush EndPoint="1.7,0.603" StartPoint="0.3,0.603"> <GradientStop Color="White" Offset="1"/> <GradientStop Color="Black" Offset="0.009"/> </LinearGradientBrush> </Setter.Value> </Setter> </Style> Then use it like this: <Grid> <Rectangle Style="{StaticResource ShadowRectStyle}"/> </Grid>
WPF border animation not working
I am trying to put an animation on a border as follows <LinearGradientBrush x:Key="RedButtonBrushUp" StartPoint=".5,0" EndPoint=".5,1"> <GradientStop Color="#ffaaaa" Offset="0"/> <GradientStop Color="#cc6666" Offset="0.6"/> <GradientStop Color="#bb2222" Offset="1"/> </LinearGradientBrush> <LinearGradientBrush x:Key="ButtonBrushUp" StartPoint=".5,0" EndPoint=".5,1"> <GradientStop Color="#aaccff" Offset="0"/> <GradientStop Color="#7799ff" Offset="0.6"/> <GradientStop Color="#555599" Offset="1"/> </LinearGradientBrush> <Border x:Name="BorderUp" BorderThickness="2,2,2,2" CornerRadius="4,4,4,4" Background="{StaticResource RedButtonBrushUp}"> <Border.Triggers> <EventTrigger RoutedEvent="Border.Loaded"> <BeginStoryboard> <Storyboard > <DoubleAnimation Storyboard.TargetName="BorderUp" Storyboard.TargetProperty="Background" RepeatBehavior="Forever" AutoReverse="True" To="{StaticResource ButtonBrushUp}" Duration="0:0:0.5" ></DoubleAnimation> </Storyboard> </BeginStoryboard> </EventTrigger> </Border.Triggers> </Border> But it says {StaticResource ButtonBrushUp} is an invalid type for this. What am I doing wrong?
The To can't accept such a change needed for the gradient brush stops. Here is a working example of what you are trying to do <Window.Resources> <Storyboard x:Key="OnLoaded1"> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="myBorder"> <EasingColorKeyFrame KeyTime="0:0:1" Value="#FFC53838"/> </ColorAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Window.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Loaded" SourceName="myBorder"> <BeginStoryboard Storyboard="{StaticResource OnLoaded1}"/> </EventTrigger> </Window.Triggers> <Grid> <StackPanel x:Name="stackPanel" Orientation="Vertical" HorizontalAlignment="Center"> <Border x:Name="myBorder" Background="#99FFFFFF" BorderThickness="3" Margin="0,60,0,20" Padding="20" > <Border.BorderBrush> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="White" Offset="1"/> </LinearGradientBrush> </Border.BorderBrush> <TextBlock> This example shows how to have a border change color after an initial load. </TextBlock> </Border> </StackPanel>
Not able to use XAML extracted from Adobe Illustrator in WPF
I've created a design in AdobeIllustrator. Then I opened design in Microsoft Expression Blend, and got entire XAML code of the design. I tried to apply the XAML and create custom button with the same shape as in my original design. This is what I did: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style x:Key="ShutdownButton" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Canvas> <Path Stretch="Fill" Width="48.901" Height="48.901" Data="F1M1499.9043,24.47363C1492.73633,24.47363,1486.90576,30.3046899999999,1486.90576,37.47119C1486.90576,37.47119,1486.90576,60.37646,1486.90576,60.37646C1486.90576,67.54395,1492.73633,73.375,1499.9043,73.375C1499.9043,73.375,1522.80811,73.375,1522.80811,73.375C1529.97607,73.375,1535.80713,67.54395,1535.80713,60.37646C1535.80713,60.37646,1535.80713,37.47119,1535.80713,37.47119C1535.80713,30.3046899999999,1529.97607,24.47363,1522.80811,24.47363C1522.80811,24.47363,1499.9043,24.47363,1499.9043,24.47363z" Canvas.Left="1486.906" Canvas.Top="30.395"> <Path.Fill> <LinearGradientBrush EndPoint="-0.282,0.5" StartPoint="1.225,0.5"> <GradientStop Color="#FF80A6CE" Offset="0"/> <GradientStop Color="#FF80A6CE" Offset="0.0056199999526143074"/> <GradientStop Color="#FF35567B" Offset="0.0730300024151802"/> <GradientStop Color="#FFE3E5E9" Offset="0.5"/> <GradientStop Color="#FFBDCEDB" Offset="0.61798000335693359"/> <GradientStop Color="sc#1, 0.481651038, 0.5958579, 0.699703157" Offset="0.72800544642086606"/> <GradientStop Color="sc#1, 0.423206866, 0.5500373, 0.6810892" Offset="0.76080161280657421"/> <GradientStop Color="sc#1, 0.3457467, 0.489308178, 0.65641886" Offset="0.78334873384059733"/> <GradientStop Color="sc#1, 0.253189534, 0.4167429, 0.6269403" Offset="0.80115865841833056"/> <GradientStop Color="sc#1, 0.201556265, 0.376262128, 0.610495567" Offset="0.8089900016784668"/> <GradientStop Color="#FF7CA5CD" Offset="0.8089900016784668"/> <GradientStop Color="#FF224F5E" Offset="1"/> </LinearGradientBrush> </Path.Fill> </Path> </Canvas> <Canvas> <Path Stretch="Fill" Width="41.629" Height="41.629" Data="F1M1499.9043,28.10986C1494.74219,28.10986,1490.54199,32.30908,1490.54199,37.47119C1490.54199,37.47119,1490.54199,60.37646,1490.54199,60.37646C1490.54199,65.5385699999999,1494.74219,69.7387699999999,1499.9043,69.7387699999999C1499.9043,69.7387699999999,1522.80811,69.7387699999999,1522.80811,69.7387699999999C1527.97021,69.7387699999999,1532.1709,65.5385699999999,1532.1709,60.37646C1532.1709,60.37646,1532.1709,37.47119,1532.1709,37.47119C1532.1709,32.30908,1527.97021,28.10986,1522.80811,28.10986C1522.80811,28.10986,1499.9043,28.10986,1499.9043,28.10986z" Canvas.Left="1490.542" Canvas.Top="34.032"> <Path.Fill> <LinearGradientBrush EndPoint="0.5,1.175" StartPoint="0.5,-0.157"> <GradientStop Color="#FF80A6CE" Offset="0"/> <GradientStop Color="#FF80A6CE" Offset="0.0056199999526143074"/> <GradientStop Color="#FF35567B" Offset="0.0730300024151802"/> <GradientStop Color="#FFE3E5E9" Offset="0.5"/> <GradientStop Color="#FFBDCEDB" Offset="0.61798000335693359"/> <GradientStop Color="sc#1, 0.481651038, 0.5958579, 0.699703157" Offset="0.72800544642086606"/> <GradientStop Color="sc#1, 0.423206866, 0.5500373, 0.6810892" Offset="0.76080161280657421"/> <GradientStop Color="sc#1, 0.3457467, 0.489308178, 0.65641886" Offset="0.78334873384059733"/> <GradientStop Color="sc#1, 0.253189534, 0.4167429, 0.6269403" Offset="0.80115865841833056"/> <GradientStop Color="sc#1, 0.201556265, 0.376262128, 0.610495567" Offset="0.8089900016784668"/> <GradientStop Color="#FF7CA5CD" Offset="0.8089900016784668"/> <GradientStop Color="#FF224F5E" Offset="1"/> </LinearGradientBrush> </Path.Fill> </Path> </Canvas> <Canvas> <Path Fill="Black" Stretch="Fill" Width="37.588" Height="37.589" Data="F1M1499.9043,30.12988C1495.85596,30.12988,1492.56201,33.4233400000001,1492.56201,37.47119C1492.56201,37.47119,1492.56201,60.37646,1492.56201,60.37646C1492.56201,64.4248,1495.85596,67.71875,1499.9043,67.71875C1499.9043,67.71875,1522.80811,67.71875,1522.80811,67.71875C1526.85742,67.71875,1530.15039,64.4248,1530.15039,60.37646C1530.15039,60.37646,1530.15039,37.47119,1530.15039,37.47119C1530.15039,33.4233400000001,1526.85742,30.12988,1522.80811,30.12988C1522.80811,30.12988,1499.9043,30.12988,1499.9043,30.12988z" Canvas.Left="1492.562" Canvas.Top="36.052"/> </Canvas> <Canvas> <Path Stretch="Fill" Width="36.78" Height="36.78" Data="F1M1499.9043,30.5341800000001C1496.07813,30.5341800000001,1492.9668,33.646,1492.9668,37.47119C1492.9668,37.47119,1492.9668,60.37646,1492.9668,60.37646C1492.9668,64.20264,1496.07813,67.3144500000001,1499.9043,67.3144500000001C1499.9043,67.3144500000001,1522.80811,67.3144500000001,1522.80811,67.3144500000001C1526.63379,67.3144500000001,1529.74658,64.20264,1529.74658,60.37646C1529.74658,60.37646,1529.74658,37.47119,1529.74658,37.47119C1529.74658,33.646,1526.63379,30.5341800000001,1522.80811,30.5341800000001C1522.80811,30.5341800000001,1499.9043,30.5341800000001,1499.9043,30.5341800000001z" Canvas.Left="1492.967" Canvas.Top="36.456"> <Path.Fill> <RadialGradientBrush Center="0.509,-0.259" GradientOrigin="0.509,-0.259" RadiusX="1.572" RadiusY="1.572"> <GradientStop Color="#FFFEFEFE" Offset="0"/> <GradientStop Color="sc#1, 0.91495055, 0.5010311, 0.5039547" Offset="0.0692620569139719"/> <GradientStop Color="#FFEC1B23" Offset="0.2921299934387207"/> <GradientStop Color="#FF9E1218" Offset="0.64607000350952148"/> <GradientStop Color="#FF141D2D" Offset="1"/> </RadialGradientBrush> </Path.Fill> </Path> </Canvas> <Canvas> <Path Stretch="Fill" Width="36.78" Height="36.78" Data="F1M1499.9043,30.5341800000001C1496.07813,30.5341800000001,1492.9668,33.646,1492.9668,37.47119C1492.9668,37.47119,1492.9668,60.37646,1492.9668,60.37646C1492.9668,64.20264,1496.07813,67.3144500000001,1499.9043,67.3144500000001C1499.9043,67.3144500000001,1522.80811,67.3144500000001,1522.80811,67.3144500000001C1526.63379,67.3144500000001,1529.74658,64.20264,1529.74658,60.37646C1529.74658,60.37646,1529.74658,37.47119,1529.74658,37.47119C1529.74658,33.646,1526.63379,30.5341800000001,1522.80811,30.5341800000001C1522.80811,30.5341800000001,1499.9043,30.5341800000001,1499.9043,30.5341800000001z" Canvas.Left="1492.967" Canvas.Top="36.456"> <Path.Fill> <RadialGradientBrush Center="0.509,-0.259" GradientOrigin="0.509,-0.259" RadiusX="1.572" RadiusY="1.572"> <GradientStop Color="#FFFEFEFE" Offset="0"/> <GradientStop Color="sc#1, 0.91495055, 0.5010311, 0.5039547" Offset="0.0692620569139719"/> <GradientStop Color="#FFEC1B23" Offset="0.2921299934387207"/> <GradientStop Color="#FF9E1218" Offset="0.64607000350952148"/> <GradientStop Color="#FF141D2D" Offset="1"/> </RadialGradientBrush> </Path.Fill> </Path> </Canvas> <Canvas> <Path Stretch="Fill" Width="34.356" Height="34.357" Data="F1M1528.53418,60.37646C1528.53418,63.5385699999999,1525.97168,66.10303,1522.80811,66.10303C1522.80811,66.10303,1499.9043,66.10303,1499.9043,66.10303C1496.74219,66.10303,1494.17773,63.5385699999999,1494.17773,60.37646C1494.17773,60.37646,1494.17773,37.47119,1494.17773,37.47119C1494.17773,34.30908,1496.74219,31.7456099999999,1499.9043,31.7456099999999C1499.9043,31.7456099999999,1522.80811,31.7456099999999,1522.80811,31.7456099999999C1525.97168,31.7456099999999,1528.53418,34.30908,1528.53418,37.47119C1528.53418,37.47119,1528.53418,60.37646,1528.53418,60.37646z" Canvas.Left="1494.178" Canvas.Top="37.667"> <Path.Fill> <RadialGradientBrush Center="0.526,1.261" GradientOrigin="0.526,1.261" RadiusX="1.188" RadiusY="1.187"> <GradientStop Color="#FFEC1B23" Offset="0"/> <GradientStop Color="#FFEC1B23" Offset="0.2921299934387207"/> <GradientStop Color="#FFCD2123" Offset="0.64607000350952148"/> <GradientStop Color="#FF8F2224" Offset="1"/> </RadialGradientBrush> </Path.Fill> </Path> </Canvas> <Canvas> <Path Fill="#FFFEFEFE" Stretch="Fill" Width="1.961" Height="9.576" Data="F1M1510.37646,38.4262699999999C1510.37646,38.4262699999999,1510.37646,48.0019500000001,1510.37646,48.0019500000001C1510.37646,48.0019500000001,1512.3374,48.0019500000001,1512.3374,48.0019500000001C1512.3374,48.0019500000001,1512.3374,38.4262699999999,1512.3374,38.4262699999999C1512.3374,38.4262699999999,1510.37646,38.4262699999999,1510.37646,38.4262699999999z" Canvas.Left="1510.376" Canvas.Top="44.348"/> </Canvas> <Canvas> <Path Fill="#FFFEFEFE" Stretch="Fill" Width="18.806" Height="18.429" Data="F1M1513.9707,40.9926800000001C1513.9707,40.9926800000001,1513.9707,43.05762,1513.9707,43.05762C1516.78809,44.1196299999999,1518.79883,46.8349599999999,1518.79883,50.0180700000001C1518.79883,54.12256,1515.46094,57.46191,1511.35693,57.46191C1507.25195,57.46191,1503.91309,54.12256,1503.91309,50.0180700000001C1503.91309,46.8349599999999,1505.92578,44.1196299999999,1508.74316,43.05762C1508.74316,43.05762,1508.74316,40.9926800000001,1508.74316,40.9926800000001C1504.82715,42.12842,1501.95361,45.74072,1501.95361,50.0180700000001C1501.95361,55.20361,1506.17236,59.42139,1511.35693,59.42139C1516.5415,59.42139,1520.75977,55.20361,1520.75977,50.0180700000001C1520.75977,45.74072,1517.88623,42.12842,1513.9707,40.9926800000001z" Canvas.Left="1501.954" Canvas.Top="46.914"/> </Canvas> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> I saved this in Resource Dictionary file and included dictionary in App.xaml. When I try to apply Style on my WPF application with ... I don't get the desired design. Actually, the button is not visible at all. Can someone help me with the issue?
Ok, I must have done something wrong when pasting generated xaml. Here is a working version: <Path Fill="Black" Stretch="Fill" Width="37.588" Height="37.589" Data="F1M1499.9043,30.12988C1495.85596,30.12988,1492.56201,33.4233400000001,1492.56201,37.47119C1492.56201,37.47119,1492.56201,60.37646,1492.56201,60.37646C1492.56201,64.4248,1495.85596,67.71875,1499.9043,67.71875C1499.9043,67.71875,1522.80811,67.71875,1522.80811,67.71875C1526.85742,67.71875,1530.15039,64.4248,1530.15039,60.37646C1530.15039,60.37646,1530.15039,37.47119,1530.15039,37.47119C1530.15039,33.4233400000001,1526.85742,30.12988,1522.80811,30.12988C1522.80811,30.12988,1499.9043,30.12988,1499.9043,30.12988z" Canvas.Left="1492.562" Canvas.Top="36.052"/> <Path Stretch="Fill" Width="36.78" Height="36.78" Data="F1M1499.9043,30.5341800000001C1496.07813,30.5341800000001,1492.9668,33.646,1492.9668,37.47119C1492.9668,37.47119,1492.9668,60.37646,1492.9668,60.37646C1492.9668,64.20264,1496.07813,67.3144500000001,1499.9043,67.3144500000001C1499.9043,67.3144500000001,1522.80811,67.3144500000001,1522.80811,67.3144500000001C1526.63379,67.3144500000001,1529.74658,64.20264,1529.74658,60.37646C1529.74658,60.37646,1529.74658,37.47119,1529.74658,37.47119C1529.74658,33.646,1526.63379,30.5341800000001,1522.80811,30.5341800000001C1522.80811,30.5341800000001,1499.9043,30.5341800000001,1499.9043,30.5341800000001z" Canvas.Left="1492.967" Canvas.Top="36.456"> <Path.Fill> <RadialGradientBrush Center="0.509,-0.259" GradientOrigin="0.509,-0.259" RadiusX="1.572" RadiusY="1.572"> <GradientStop Color="#FFFEFEFE" Offset="0"/> <GradientStop Color="sc#1, 0.91495055, 0.5010311, 0.5039547" Offset="0.0692620569139719"/> <GradientStop Color="#FFEC1B23" Offset="0.2921299934387207"/> <GradientStop Color="#FF9E1218" Offset="0.64607000350952148"/> <GradientStop Color="#FF141D2D" Offset="1"/> </RadialGradientBrush> </Path.Fill> </Path> <Path Stretch="Fill" Width="34.356" Height="34.357" Data="F1M1528.53418,60.37646C1528.53418,63.5385699999999,1525.97168,66.10303,1522.80811,66.10303C1522.80811,66.10303,1499.9043,66.10303,1499.9043,66.10303C1496.74219,66.10303,1494.17773,63.5385699999999,1494.17773,60.37646C1494.17773,60.37646,1494.17773,37.47119,1494.17773,37.47119C1494.17773,34.30908,1496.74219,31.7456099999999,1499.9043,31.7456099999999C1499.9043,31.7456099999999,1522.80811,31.7456099999999,1522.80811,31.7456099999999C1525.97168,31.7456099999999,1528.53418,34.30908,1528.53418,37.47119C1528.53418,37.47119,1528.53418,60.37646,1528.53418,60.37646z" Canvas.Left="1494.178" Canvas.Top="37.667"> <Path.Fill> <RadialGradientBrush Center="0.526,1.261" GradientOrigin="0.526,1.261" RadiusX="1.188" RadiusY="1.187"> <GradientStop Color="#FFEC1B23" Offset="0"/> <GradientStop Color="#FFEC1B23" Offset="0.2921299934387207"/> <GradientStop Color="#FFCD2123" Offset="0.64607000350952148"/> <GradientStop Color="#FF8F2224" Offset="1"/> </RadialGradientBrush> </Path.Fill> </Path> <Path Fill="#FFFEFEFE" Stretch="Fill" Width="1.961" Height="9.576" Data="F1M1510.37646,38.4262699999999C1510.37646,38.4262699999999,1510.37646,48.0019500000001,1510.37646,48.0019500000001C1510.37646,48.0019500000001,1512.3374,48.0019500000001,1512.3374,48.0019500000001C1512.3374,48.0019500000001,1512.3374,38.4262699999999,1512.3374,38.4262699999999C1512.3374,38.4262699999999,1510.37646,38.4262699999999,1510.37646,38.4262699999999z" Canvas.Left="1510.376" Canvas.Top="44.348"/> <Path Fill="#FFFEFEFE" Stretch="Fill" Width="18.806" Height="18.429" Data="F1M1513.9707,40.9926800000001C1513.9707,40.9926800000001,1513.9707,43.05762,1513.9707,43.05762C1516.78809,44.1196299999999,1518.79883,46.8349599999999,1518.79883,50.0180700000001C1518.79883,54.12256,1515.46094,57.46191,1511.35693,57.46191C1507.25195,57.46191,1503.91309,54.12256,1503.91309,50.0180700000001C1503.91309,46.8349599999999,1505.92578,44.1196299999999,1508.74316,43.05762C1508.74316,43.05762,1508.74316,40.9926800000001,1508.74316,40.9926800000001C1504.82715,42.12842,1501.95361,45.74072,1501.95361,50.0180700000001C1501.95361,55.20361,1506.17236,59.42139,1511.35693,59.42139C1516.5415,59.42139,1520.75977,55.20361,1520.75977,50.0180700000001C1520.75977,45.74072,1517.88623,42.12842,1513.9707,40.9926800000001z" Canvas.Left="1501.954" Canvas.Top="46.914"/> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsFocused" Value="True"/> <Trigger Property="IsDefaulted" Value="True"/> <Trigger Property="IsMouseOver" Value="True"/> <Trigger Property="IsPressed" Value="True"/> <Trigger Property="IsEnabled" Value="False"/> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> But, one more thing that I'm interested in is this: Is there a way to set a font style property when defining new style? Just like I set Width and Height?
silverlight styles
<navigation:Page.Resources> <Style x:Key="PageBackground" TargetType="Grid"> <Setter Property="Background"> <Setter.Value> <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"> <GradientStop Color="White" Offset="1"/> <GradientStop Color="Silver"/> </LinearGradientBrush> <Path x:Name="shinePath" Data="M0,0 L0,300 C-5.5,306.5 40,68 215,0 z" Stretch="Fill" Opacity="0.1"> <Path.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" SpreadMethod="Pad"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="#00FFFFFF" Offset="0.871"/> </LinearGradientBrush> </Path.Fill> </Path> </Setter.Value> </Setter> </Style> </navigation:Page.Resources> error- property 'Value' is set more then once
You've got a single <Setter.Value> element, it can contain only one child elment. Looks to me as though the Path is intended for a different property. Can't think what though Grid doesn't have a property that can accept a path. Do you intend the path to be the content of the Grid?