我有一个网格和两个stackpanels.I已经制作动画打开门混合有不同分辨率设置门的问题。 这是我的代码,在1024,768分辨率下工作正常。
<StackPanel.Background>
<ImageBrush ImageSource="Assets/left.jpg"></ImageBrush>
</StackPanel.Background>
</StackPanel>
<StackPanel x:Name="stackPanel1" Width="512" Height="{Binding ElementName=mygrid,Path=ActualHeight}" HorizontalAlignment="Right">
<StackPanel.Background>
<ImageBrush ImageSource="Assets/right.jpg"></ImageBrush>
</StackPanel.Background>
</StackPanel>
</Grid>``
答案 0 :(得分:0)
试试这个
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!--used for calculating height and width of door-->
<Grid x:Name="Door" Grid.Column="0" ></Grid>
<StackPanel Grid.ColumnSpan="2" x:Name="stackPanel1" Width="{Binding ElementName=Door,Path=ActualWidth}" Height="{Binding ElementName=Door,Path=ActualHeight}" HorizontalAlignment="Left">
<StackPanel.Background>
<ImageBrush ImageSource="Assets/left.jpg" Stretch="Fill"></ImageBrush>
</StackPanel.Background>
</StackPanel>
<StackPanel Grid.ColumnSpan="2" x:Name="stackPanel2" Width="{Binding ElementName=Door,Path=ActualWidth}" Height="{Binding ElementName=Door,Path=ActualHeight}" HorizontalAlignment="Right">
<StackPanel.Background>
<ImageBrush ImageSource="Assets/right.jpg" Stretch="Fill"></ImageBrush>
</StackPanel.Background>
</StackPanel>
</Grid>