簡體   English   中英

控制焦點面板

[英]Panel on Control Focus

我正在開發一個多語言 WPF 應用程序。 用戶必須同時提供多種語言的輸入。 這有效,但它也會移動其下方的字段。

我正在尋找的是有點像這樣:

到目前為止我所做的如下:

    <Label Grid.Column="0" Grid.Row="0"  Content="Field1" Padding="0" Style="{DynamicResource ControlLabel}"/>
<Label Grid.Column="1" Grid.Row="0" Content=":" Style="{DynamicResource ControlLabelMiddle}"/>
<StackPanel Grid.Column="2" Grid.Row="0" Margin="3"  Style="{Binding RelativeSource={RelativeSource TemplatedParent}}">
    <TextBox x:Name="txtField1" Height="23" GotKeyboardFocus="txtField1_GotKeyboardFocus" />
    <Grid Background="White" x:Name="pnlField1" Visibility="Collapsed" Panel.ZIndex="99">
        <Border BorderBrush="blue" BorderThickness="3">
        <StackPanel Background="White" Margin="5">
            <StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
            <Label Content="Language2" HorizontalAlignment="Left"/>
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="10" Padding="2" >
                <Hyperlink Hyperlink.Click="btnClose_Click" x:Name="btnClose" >X</Hyperlink>
                </TextBlock>
            </StackPanel>
            <TextBox x:Name="txtField_Second" Height="23" Width="280" />
        </StackPanel>
        </Border>
    </Grid>
</StackPanel>

當上面的控件獲得焦點時,我的第二語言面板就會出現。 但它把我的下一行控件向下移動,看起來不太好。

要防止面板移動,請嘗試將它們放置在Grid ,而不是StackPanel 這使您能夠明確定義每個元素在Grid放置位置。 StackPanel ,元素“堆疊”在彼此的頂部。 隨着面板內容的變化,每個元素在“堆棧”中占據的空間量也有可能發生變化。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM