0
我有一個橢圓形的「width ='auto'」,我想要一個圓,所以不可能設置「height ='auto'」,因爲如果用戶調整大小窗口,圓形將是一個橢圓。我試過「Height ='{Binding ElementName = TheLeft,Path = Width}'」。將一個動態元素的值賦給另一個元素
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<!--<Ellipse x:Name="TheLeft" Fill="Pink" Grid.Column="0" Height="{Binding ElementName=TheLeft, Path=Width}" Width="auto" VerticalAlignment="Bottom"/>-->
<!-- I've set Height="200" in the uncommented element -->
<Ellipse x:Name="TheLeft" Fill="Pink" Grid.Column="0" Height="200" Width="auto" VerticalAlignment="Bottom"/>
<Rectangle Fill="Red" Grid.Column="1" RadiusX="50" RadiusY="40"/>
<Ellipse Fill="Pink" Grid.Column="2" Height="200" Width="auto" VerticalAlignment="Bottom"/>
</Grid>
</Page>