RTExeption
RTExeption

Reputation: 131

icon inside small button wpf

I am trying to add icon inside small Button but it doesn't enters as desired,

here my xaml:

<Button x:Name="eye_button"  BorderBrush="{x:Null}"   Margin="234,0,0,0"  Height="15" Width="15">                                     
        <materialDesign:PackIcon Kind="Eye"   Foreground="Black" />
  </Button>

Here how it's looks like:

enter image description here

The left squre it's the button, in the right it's the icon

Upvotes: 3

Views: 8354

Answers (2)

nurullo sulaimonov
nurullo sulaimonov

Reputation: 37

 <Button
    Width="15"
    Height="15"
    Padding="0"
    HorizontalAlignment="Center"
    HorizontalContentAlignment="Center"
    VerticalContentAlignment="Center"
    Background="Transparent"
    BorderThickness="0"
    Foreground="Red">

    <materialDesign:PackIcon
        Width="15"
        Height="15"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Foreground="Black"
        Kind="ArrowBack" />
</Button>

Make sure you put padding to 0

enter image description here

Upvotes: 2

mm8
mm8

Reputation: 169270

Try this:

<Button x:Name="eye_button" BorderBrush="{x:Null}"  Margin="234,0,0,0" HorizontalAlignment="Left">
    <materialDesign:PackIcon Kind="Eye" Foreground="Black" Width="15" Height="15" />
</Button>

It should look like this at runtime:

enter image description here

Upvotes: 4

Related Questions