简体   繁体   中英

WPF RepeatButton content alignment?

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"/>

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" />

try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM