c# - 打开组合框会移动其他控件

标签 c# xaml combobox uwp

enter image description here

我定义了一个 RelativePanel,它在左侧包含一个组合框,在组合框的右侧包含一个切换开关。但出于某种原因,当单击组合框将其打开时,会弹出一个包含内容的弹出窗口,而组合框会消失。 (并通过关闭弹出窗口再次可见)。因此,包含组合框标签的文本 block 向右移动,弹出窗口与我的切换开关重叠...... 如何防止此文本 block 移动以防止弹出窗口与切换开关重叠? (导致此问题的是 comboImageSources,而不是其他组合框)

<RelativePanel x:Name="topBar" Grid.Row="0" Padding="12,0,12,0">

        <!-- left side -->
        <TextBlock x:Name="OCRSettings_Language"
                   Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                   Text="OCR Language:"
                   Margin="0,0,12,0"
                   RelativePanel.AlignLeftWithPanel="True"
                   RelativePanel.AlignVerticalCenterWithPanel="True" />

        <ComboBox x:Uid="comboSettingsOCRLanguage" x:Name="comboOCRLanguages"
                  AutomationProperties.Name="[comboSettingsOCRLanguage]"
                  ItemsSource="{x:Bind Settings.OCRLanguages}"
                  ItemTemplate="{StaticResource ComboOCRLanguageTemplate}"
                  RelativePanel.RightOf="OCRSettings_Language"
                  RelativePanel.AlignVerticalCenterWithPanel="True"
                  Margin="0,0,12,0"
                  TabIndex="8"
                  Loaded="comboOCRLanguages_Loaded" />

        <!-- right side -->
        <TextBlock x:Name="OCRSettings_ImageSource"
                   Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                   Text="Image Source:"
                   Margin="0,0,10,0"
                   RelativePanel.LeftOf="comboImageSources"
                   RelativePanel.AlignVerticalCenterWithPanel="True" />

        <ComboBox x:Uid="comboImageSources" x:Name="comboImageSources"
                  AutomationProperties.Name="[comboImageSources]"
                  ItemsSource="{x:Bind Settings.ImageSources}"
                  ItemTemplate="{StaticResource ComboImageSourceTemplate}"
                  RelativePanel.LeftOf="OCRSettings_ColumnMode"
                  RelativePanel.AlignVerticalCenterWithPanel="True"
                  Margin="0,0,20,0"
                  TabIndex="4"
                  Loaded="comboImageSources_Loaded"  />

最佳答案

您必须将 ComboBoxWidth 属性设置为某个固定值,因为当您打开其中的选项时它会变为非常小的值。

关于c# - 打开组合框会移动其他控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42345304/

相关文章:

c# - 组合框的项目为空时是否为空?

c# - 协调 2 个长度不同的数组 c#

c# - 在 4 个位置实例化 4 个预制件,打乱顺序,Unity Engine C#

c# - 带有 ListViewItem ContextMenu 的 g.cs 文件出错

c# - 使用 aspxgridview 的值填充 GridViewDataComboBoxColumn

combobox - Extjs4 网格编辑器远程组合框 displayValue

c# - 如何 "query"列表<T>

c# - 从客户端调用 MVC Web API Controller 方法

c# - 如何在选项卡 View 选择的 View (用户控件)中将焦点设置到文本框

wpf - 如何将命令附加到 CheckBox 的选中和取消选中?