2016-07-15 26 views
0

Ich habe eine Gruppenbox, die ein Stack Panel enthält, das eine Combo Box (A) und ein Textfeld enthält. Und ich habe ein weiteres Stack-Panel (B), das ein Kombinationsfeld und ein Label enthält. Ich würde die Combo Box B auf die gleiche Ebene wie Combo Box A (selbe y) mit Xaml-Code setzen. Bitte beachten Sie, dass die GroupBox und und das Stack Panel (B) in einem Raster in der gleichen Reihe, verschiedenen Spalten platziert sind.wpf kann keine Kontrollkoordinaten finden

Ich versuche, die y-Koordinate des Kombinationsfelds (B) an die y-Koordinate des Kombinationsfelds (A) zu binden.

Wo finde ich die Koordinateninformationen von wpf-Steuerelementen im Visual Studio-Eigenschaftenfenster?

<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

bitte Ihre aktuellen XAML-Markup schreiben. screenshot kann auch helfen. – ASh

+0

Irgendwelche Ideen Jungs? – TheOne

Antwort

0

ein enges äquivalent wäre mit Margin Eigenschaft y-Koordinate der Verwendung ... aber es nach dem ersten Resize-Versuch brechen wird.

ich denke, es möglich ist, Margin auf Größenänderungen zu aktualisieren, aber ich würde mit einem komplexeren Layout beginnen, wie folgt aus:

<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

Das löst mein Problem, ohne in die Koordinatenwelt einzutauchen. Vielen Dank – TheOne