WPF RepeatButton content alignment?

291 Views Asked by At

I have a repeatbutton in WPF. The height of buttun is set to 10 because of the space limitation. Now the content of the repeatbutton is not displaying because, I think, the alignment of the content has some problem.

I am wondering is there any way to change the alignment of the content so that it can show up even when the height of the repeatbutton is small?

Here is my xaml:

<RepeatButton Name="ABPPlus" Height="10" Click="btnABPPlus_Click"  Content="+" 
    Delay="500" Interval="100" Width="30"/>
2

There are 2 best solutions below

0
On BEST ANSWER

try this

    <Button Height="10" Width="50"  >
        <Button.Content>
            <Canvas>
                <TextBlock Canvas.Top="-7" >fff</TextBlock>
            </Canvas>
        </Button.Content>
    </Button>
2
On

I'm not sure that this will fix your issue, but in order to rotate the Content of your RepeatButton, you should use a RotateTransform on it. Try this:

<RepeatButton Name="ABPPlus" Height="10" Click="btnABPPlus_Click" Delay="500" 
    Interval="100" Width="30">
    <TextBlock Text="+">
        <TextBlock.LayoutTransform>
            <RotateTransform Angle="270" /> 
        </TextBlock.LayoutTransform>
    </TextBlock>
</RepeatButton>

A better solution would just be to use a smaller FontSize:

<RepeatButton Name="ABPPlus" Height="10" Click="btnABPPlus_Click"  Content="+" 
    Delay="500" Interval="100" Width="30" FontSize="10" />