Gradient Button by Rectangle : Button « Windows Presentation Foundation « C# / C Sharp






Gradient Button by Rectangle

Gradient Button by Rectangle
       
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
    <Grid x:Name="LayoutRoot">
        <DockPanel RenderTransformOrigin="0.5,0.5" Margin="98,116,231,80" LastChildFill="False">
            <DockPanel.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                    <SkewTransform AngleX="0" AngleY="0"/>
                    <RotateTransform Angle="0"/>
                    <TranslateTransform X="0" Y="0"/>
                </TransformGroup>
            </DockPanel.RenderTransform>
            <Rectangle Stroke="sc#1, 0.3, 0.3, 0.9" RadiusX="14.5" RadiusY="14.5" Height="110" 
                 x:Name="Rectangle" RenderTransformOrigin="0.5,0.5" MinHeight="0" Width="110" 
                 DockPanel.Dock="Bottom">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                        <LinearGradientBrush.RelativeTransform>
                            <TransformGroup>
                                <TranslateTransform X="-0.5" Y="-0.5"/>
                                <ScaleTransform ScaleX="1" ScaleY="1"/>
                                <SkewTransform AngleX="0" AngleY="0"/>
                                <RotateTransform Angle="-90"/>
                                <TranslateTransform X="0.5" Y="0.5"/>
                                <TranslateTransform X="0" Y="0"/>
                            </TransformGroup>
                        </LinearGradientBrush.RelativeTransform>
                        <LinearGradientBrush.GradientStops>
                            <GradientStopCollection>
                                <GradientStop Color="Red" Offset="0"/>
                                <GradientStop Color="sc#0, 1, 1, 1" Offset="1"/>
                                <GradientStop Color="sc#0, 0, 0, 0.2" Offset="0.4"/>
                                <GradientStop Color="sc#1, 0, 0, 0" Offset="0.8"/>
                                <GradientStop Color="sc#1, 0, 0, 0.6" Offset="0.1"/>
                                <GradientStop Color="Red" Offset="0.3"/>
                                <GradientStop Color="Yellow" Offset="0.9"/>
                            </GradientStopCollection>
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Rectangle.Fill>
                <Rectangle.RenderTransform>
                    <TransformGroup>
                        <TranslateTransform X="0" Y="0"/>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                        <SkewTransform AngleX="0" AngleY="0"/>
                        <RotateTransform Angle="0"/>
                        <TranslateTransform X="0" Y="0"/>
                        <TranslateTransform X="0" Y="0"/>
                    </TransformGroup>
                </Rectangle.RenderTransform>
            </Rectangle>
        </DockPanel>
    </Grid>
</Window>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Gradient background buttonGradient background button
2.Shaking ButtonShaking Button
3.Default ButtonDefault Button
4.Button with Image sourceButton with Image source
5.Button with OpacityMaskButton with OpacityMask
6.The button and text block are up-side down in the custom coordinate system.The button and text block are up-side down in the custom coordinate system.
7.TextBox as Button ContentTextBox as Button Content
8.Button IsMouseOverButton IsMouseOver
9.Using common TextElement attached properties
10.Button HorizontalAlignment="Center"Button HorizontalAlignment=
11.Fish Eye ButtonsFish Eye Buttons
12.Enlarge Button In XamlEnlarge Button In Xaml
13.Click to rotate a ButtonClick to rotate a Button
14.Click to scale a ButtonClick to scale a Button
15.Change Button Alignment, Margin, FontSize and Padding in Style SettingChange Button Alignment, Margin, FontSize and Padding in Style Setting
16.Rotated 35 degreesRotated 35 degrees
17.Set VerticalAlignment/HorizontalAlignment for ButtonSet VerticalAlignment/HorizontalAlignment for Button
18.Button with Inline Property TriggerButton with Inline Property Trigger
19.The implementation of our button's Click event handler in XamlThe implementation of our button's Click event handler in Xaml
20.To add a button control and a text block to the canvas
21.Button mouse down eventButton mouse down event
22.Button mouse down previewButton mouse down preview
23.Simple Custom ButtonSimple Custom Button
24.Custom Shaped ButtonCustom Shaped Button
25.Set Delay and Interval for RepeatButtonSet Delay and Interval for RepeatButton
26.A simple template for a round buttonA simple template for a round button
27.Load style defined in Xaml and apply to the ButtonLoad style defined in Xaml and apply to the Button
28.Nested Button contentNested Button content
29.Button PreviewMouseLeftButtonDown action and MouseLeftButtonDown actionButton PreviewMouseLeftButtonDown action and MouseLeftButtonDown action
30.Button PreviewMouseDown action and MouseDown actionButton PreviewMouseDown action and MouseDown action
31.Button click actionButton click action
32.Dynamically add Button to a Grid and add Action listenerDynamically add Button to a Grid and add Action listener
33.Do event based on button nameDo event based on button name
34.Button Click event handlerButton Click event handler
35.Put Button onto a GridPut Button onto a Grid
36.Add buttons to a Canvas with codeAdd buttons to a Canvas with code