Buttons-VBForums
Results 1 to 3 of 3

Thread: Buttons

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Location
    Milan
    Posts
    810

    Buttons

    Is it possible to create round and odd shaped buttons in WPF?

    If so how?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2009
    Location
    Milan
    Posts
    810

    Re: Buttons

    I hvae this and it works well, but to make my xaml smaller can i put this into a class and reference it somehow???


    vb.net Code:
    1. <button>
    2. <button.templete>
    3.  <ControlTemplate TargetType="Button">
    4.             <Grid Height="60" Width="60" Background="#00FFFFFF">
    5.                 <Ellipse Name="Circle" StrokeThickness="1">
    6.                     <Ellipse.Fill>
    7.                         <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    8.                             <LinearGradientBrush.GradientStops>
    9.                                 <GradientStop Offset="0" Color="#FFFFFFFF" />
    10.                                 <GradientStop Offset="0.1" Color="#FFCCD4E9" />
    11.                                 <GradientStop Offset="0.47" Color="#FF4881D2" />
    12.                                 <GradientStop Offset="0.47" Color="#FF001A5A" />
    13.                                 <GradientStop Offset="0.7" Color="#FF007BD6" />
    14.                                 <GradientStop Offset="0.85" Color="#FF54DAFF" />
    15.                                 <GradientStop Offset="0.95" Color="#FF86FFFF" />
    16.                                 <GradientStop Offset="1" Color="#FFFFFFFF" />
    17.                             </LinearGradientBrush.GradientStops>
    18.                         </LinearGradientBrush>
    19.                     </Ellipse.Fill>
    20.                     <Ellipse.Stroke>
    21.                         <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
    22.                             <LinearGradientBrush.GradientStops>
    23.                                 <GradientStop Offset="0" Color="#FF6C90C4" />
    24.                                 <GradientStop Offset="0.5" Color="#FF315BB4" />
    25.                                 <GradientStop Offset="0.5" Color="#FF002091" />
    26.                                 <GradientStop Offset="1" Color="#FF08377C" />
    27.                             </LinearGradientBrush.GradientStops>
    28.                         </LinearGradientBrush>
    29.                     </Ellipse.Stroke>
    30.                 </Ellipse>
    31.  
    32.             </Grid>
    33.  
    34.             <ControlTemplate.Triggers>
    35.                 <Trigger Property="UIElement.IsMouseOver" Value="true">
    36.                     <Setter Property="Shape.Fill" TargetName="Circle">
    37.                         <Setter.Value>
    38.                             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    39.                                 <LinearGradientBrush.GradientStops>
    40.                                     <GradientStop Offset="0" Color="#FFFFFFFF" />
    41.                                     <GradientStop Offset="0.1" Color="#FFDFEDF9" />
    42.                                     <GradientStop Offset="0.47" Color="#FF3086E1" />
    43.                                     <GradientStop Offset="0.47" Color="#FF003B91" />
    44.                                     <GradientStop Offset="0.7" Color="#FF1793EF" />
    45.                                     <GradientStop Offset="0.85" Color="#FF5AD4FF" />
    46.                                     <GradientStop Offset="0.95" Color="#FFBDFFFF" />
    47.                                     <GradientStop Offset="1" Color="#FFFFFFFF" />
    48.                                 </LinearGradientBrush.GradientStops>
    49.                             </LinearGradientBrush>
    50.                         </Setter.Value>
    51.                     </Setter>
    52.  
    53.                 </Trigger>
    54.                 <Trigger Property="ButtonBase.IsPressed" Value="True">
    55.                     <Setter Property="Shape.Fill" TargetName="Circle">
    56.                         <Setter.Value>
    57.                             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    58.                                 <LinearGradientBrush.GradientStops>
    59.                                     <GradientStop Offset="0" Color="#FFC0D2F5" />
    60.                                     <GradientStop Offset="0.47" Color="#FF5E7A9C" />
    61.                                     <GradientStop Offset="0.47" Color="#FF00062D" />
    62.                                     <GradientStop Offset="0.7" Color="#FF005F9F" />
    63.                                     <GradientStop Offset="0.85" Color="#FF1FA4E2" />
    64.                                     <GradientStop Offset="0.95" Color="#FF61DAFF" />
    65.                                     <GradientStop Offset="1" Color="#FF48CFFF" />
    66.                                 </LinearGradientBrush.GradientStops>
    67.                             </LinearGradientBrush>
    68.                         </Setter.Value>
    69.                     </Setter>
    70.  
    71.                 </Trigger>
    72.             </ControlTemplate.Triggers>
    73.         </ControlTemplate>
    74. </button.templete>
    75. </button>

  3. #3
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,575

    Re: Buttons

    Putting that in code doesn't make it smaller.
    Those things should be in the XAML file, not in the .cs
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.