Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>I found This on Code-project-Article(Cool example) </h3> <p><a href="http://www.codeproject.com/KB/WPF/WPF_xaml_taskbar_window.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/WPF/WPF_xaml_taskbar_window.aspx</a></p> <p>First He create Wpf-Custom-control(you can create class inherit from Button like this) </p> <pre><code> public class ImageButton : Button { private string cornerRadius; public string CornerRadius { get { return cornerRadius; } set { cornerRadius = value; } } private string highlightBackground; public string HighlightBackground { get { return highlightBackground; } set { highlightBackground = value; } } private string pressedBackground; public string PressedBackground { get { return pressedBackground; } set { pressedBackground = value; } } } </code></pre> <p>As second step you must Create template in resource-dictionary(here is code) </p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Phone.Controls"&gt; &lt;ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type local:ImageButton}"&gt; &lt;ControlTemplate.Resources&gt; &lt;Storyboard x:Key="MouseOverButton"&gt; &lt;ThicknessAnimation Storyboard.TargetName="ButtonBackgroundBorder" Storyboard.TargetProperty="(Control.Margin)" Duration="0:0:0.05" FillBehavior="Stop" From="0,0,0,0" To="2,2,2,2" AutoReverse="True" /&gt; &lt;/Storyboard&gt; &lt;/ControlTemplate.Resources&gt; &lt;Grid x:Name="ButtonOuterGrid"&gt; &lt;Border x:Name="ButtonBackgroundBorder" CornerRadius="{Binding Path=CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" Background="{Binding Path=HighlightBackground, RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="Black" BorderThickness="0.8" Opacity="0"&gt; &lt;Border.BitmapEffect&gt; &lt;OuterGlowBitmapEffect GlowColor="#FFFFFFFF" GlowSize="2.75" Noise="0.20"/&gt; &lt;/Border.BitmapEffect&gt; &lt;/Border&gt; &lt;Border x:Name="ButtonEdgesBorder" CornerRadius="{Binding Path=CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" Opacity="1" BorderBrush="Transparent" BorderThickness="0" /&gt; &lt;Border x:Name="ButtonContentBorder" CornerRadius="{Binding Path=CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" Opacity="1" BorderThickness="1"&gt; &lt;ContentPresenter x:Name="ContentText" Width="Auto" Height="Auto" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Trigger.Setters&gt; &lt;Setter Property="Opacity" TargetName="ButtonBackgroundBorder" Value="1"/&gt; &lt;Setter Property="TextElement.Foreground" TargetName="ContentText" Value="Black"/&gt; &lt;/Trigger.Setters&gt; &lt;/Trigger&gt; &lt;EventTrigger RoutedEvent="Grid.MouseEnter" SourceName="ButtonOuterGrid"&gt; &lt;BeginStoryboard Storyboard="{StaticResource MouseOverButton}"/&gt; &lt;/EventTrigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;Style x:Key="ImageButton" TargetType="{x:Type Button}"&gt; &lt;Setter Property="Template" Value="{StaticResource ButtonTemplate}" /&gt; &lt;/Style&gt; </code></pre> <p>And this is last Step, in xaml file you must insert this custom-control</p> <pre><code>&lt;ImageButton x:Name="btnConfigs" Style="{StaticResource ImageButton}" Width="25" Height="25" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,31.125,16.418,0"&gt; &lt;Image x:Name="ImgConfigs" Stretch="Fill"/&gt; &lt;/ImageButton &gt; </code></pre> <p>and in cs file do this</p> <pre><code> this.ImgConfigs.Source="any imag-source" </code></pre> <p>also we can change this image-source on btnconfig-click event</p> <h3>With special thanks from Murray-Foxcroft for create that article </h3>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload