2013-04-30 31 views

回答

0

使用Silverlight中的元素属性绑定最好实现共享大小调整。只需将所有共享大小的元素绑定到另一个元素的宽度/高度即可。

请参考以下:

<UserControl x:Class="SLTestApp.MainPage" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:ext="clr-namespace:System.Windows.Controls.Extensions;assembly=System.Windows.Controls.Extensions" 
     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> 

    <Grid x:Name="LayoutRoot" Background="White" ext:SharedSize.IsSharedSizeScope="True"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <Grid x:Name="firstfirstGrid" Grid.Row="0"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.ColumnDefinitions> 
      <Border BorderBrush="Green" BorderThickness="2"> 
       <TextBlock x:Name="txtFirstFirst" > 
        <Run>aa</Run> 
        <LineBreak /> 
        <Run>aa</Run> 
       </TextBlock> 
      </Border> 
     </Grid> 
     <Grid x:Name="firstsecondGrid" Grid.Row="1"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.ColumnDefinitions> 
      <Border BorderBrush="Blue" BorderThickness="2"> 
       <TextBlock Text="aaaaaaaaaaaaaaaa" /> 
      </Border> 
     </Grid> 

    </Grid> 
</UserControl> 

链接全球化志愿服务青年:

http://die-rooter.de/ITworks/archives/27-SharedSize-Grid-with-Silverlight.html

希望它有用。

0
<UserControl x:Class="SLTestApp.MainPage" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:ext="clr-namespace:System.Windows.Controls.Extensions;assembly=System.Windows.Controls.Extensions" 
     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> 

    <Grid x:Name="LayoutRoot" Background="White" ext:SharedSize.IsSharedSizeScope="True"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto" /> 
      <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 
     <Grid x:Name="firstfirstGrid" Grid.Row="0"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.ColumnDefinitions> 
      <Border BorderBrush="Green" BorderThickness="2"> 
       <TextBlock x:Name="txtFirstFirst" > 
        <Run>aa</Run> 
        <LineBreak /> 
        <Run>aa</Run> 
       </TextBlock> 
      </Border> 
     </Grid> 
     <Grid x:Name="firstsecondGrid" Grid.Row="1"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.RowDefinitions> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" ext:SharedSize.SharedSizeGroup="A"/> 
      </Grid.ColumnDefinitions> 
      <Border BorderBrush="Blue" BorderThickness="2"> 
       <TextBlock Text="aaaaaaaaaaaaaaaa" /> 
      </Border> 
     </Grid> 

    </Grid> 
</UserControl>