How to bind Font Size to variable Grid Size

柔情痞子 提交于 2019-12-05 18:14:53

You can try using a ViewBox as the button's content:

<Button Grid.Row="1" Grid.Column="1">
    <Button.Content>
        <Viewbox  StretchDirection="Both" HorizontalAlignment="Stretch">
            <TextBlock Text="&#x2699;" />
        </Viewbox>
    </Button.Content>
</Button>

A ViewBox can stretch and scale his child to fill all the available space...

You could try binding to the ActualHeight instead of the Height:

<Button FontSize="{Binding ElementName=heightToBind, Path=ActualHeight.Value, Mode=OneWay}"
        Content="&#x2699;" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" />

This should work.

The * on the grid definition means take the available space as the height so it's only determined when the page layout has been prepared for layout. If the height is either unset or changed then the real height is returned in the ActualHeight property.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!