2016-07-15 10 views
0

コンボボックス(A)とテキストボックスを含むスタックパネルを含むグループボックスがあります。私はコンボボックスとラベルを含む別のスタックパネル(B)を持っています。 xamlコードを使用してコンボボックスB(同じy)と同じレベルにコンボボックスBを配置します。 GroupBoxとスタックパネル(B)は同じ行、異なる列のグリッドに配置されています。wpfで制御座標情報が見つかりません

私はコンボボックス(B)のy座標をコンボボックス(A)のy座標にバインドしようとしています。

ここで、Visual Studioのプロパティウィンドウでwpfコントロールの座標情報を見つけることができますか?

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="*" /> 
    </Grid.ColumnDefinitions> 

    <GroupBox Name="AGroupBox" Grid.Row="1" Grid.Column="0" > 
     <GroupBox.Header> 
      <Label Content="GroupBox" FontWeight="Bold" /> 
     </GroupBox.Header> 
     <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal"> 
      <ComboBox x:Name="ComboBoxA" Width="100" Height="25" VerticalAlignment="Center"/> 
      <TextBlock x:Name="TextBlockA" Width="150" VerticalAlignment="Center" Margin="10,0,0,0" Text="This a Test" /> 
     </StackPanel> 
    </GroupBox> 

    <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left"> 
     <Label x:Name="LabelB" Content="LabelB" /> 
     <ComboBox x:Name="ComboBoxB" Width="150" Height="25"/> 
    </StackPanel> 
</Grid> 
+0

現在のXAMLマークアップを投稿してください。スクリーンショットも同様に役立ちます。 – ASh

+0

アイデアみんな? – TheOne

答えて

0

y座標を使用しての近い同等のMarginプロパティを使用することでしょう...しかし、最初のサイズ変更の試みの後に破るしようとしています。

私が思う、サイズ変更にMarginを更新することが可能であるが、私はこのように、より複雑なレイアウトで始まります:

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="*" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="*" /> 
    </Grid.ColumnDefinitions> 

    <!--additional Grid used to position comboBoxes on the same height--> 
    <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"> 
     <Grid.RowDefinitions> 
      <RowDefinition/> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition/> 
     </Grid.RowDefinitions> 

     <Grid.ColumnDefinitions> 
      <ColumnDefinition/> 
      <ColumnDefinition/> 
     </Grid.ColumnDefinitions> 

     <!--group box is used as cover for the 1st column--> 
     <GroupBox Name="AGroupBox" 
        Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" > 
      <GroupBox.Header> 
       <Label Content="GroupBox" FontWeight="Bold" /> 
      </GroupBox.Header> 
     </GroupBox> 

     <!--stack panel with ComboBoxA is centered vertically in the 1st column--> 
     <StackPanel Grid.Row="1" Grid.Column="0" 
        Margin="5,0" 
        Orientation="Horizontal"> 
      <ComboBox x:Name="ComboBoxA" Width="100" Height="25" VerticalAlignment="Center"/> 
      <TextBlock x:Name="TextBlockA" Width="150" VerticalAlignment="Center" Margin="10,0,0,0" Text="This a Test" /> 
     </StackPanel> 

     <!--ComboBoxB is centered vertically in the 2nd column--> 
     <ComboBox x:Name="ComboBoxB" 
        Grid.Row="1" Grid.Column="1" 
        VerticalAlignment="Top" HorizontalAlignment="Left" 
        Width="150" Height="25"/> 

     <!--Label attached on top of ComboBoxB--> 
     <Label x:Name="LabelB" Content="LabelB" 
       Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom"/> 
    </Grid> 
</Grid> 
+0

これは、座標の世界に飛び込むことなく、私の問題を解決します。ありがとうございました – TheOne

関連する問題