相关疑难解决方法(0)

使WPF ComboBoxes填充整个列宽

我在制作ComboBox拉伸以填充整个列宽时遇到问题GridViewColumn.调整列大小时也应调整大小.

在下面的例子中,我有StackPanel一个ComboBox内部.这被设置为拉伸并且实际上将拉伸以填充StackPanel宽度.

然后,我添加ListView有一列,包含StackPanel一个ComboBox.无论是StackPanelComboBox被设置为伸展,但他们没有.我使用背景颜色来识别StackPanels 的大小,除非我设置宽度或添加元素以ComboBox使其需要更多宽度,否则没有红色.

我也尝试过HorizontalContentAlignment没有成功的游戏.

<StackPanel Height="59" Margin="45,12,38,0" VerticalAlignment="Top" Background="Green">
    <ComboBox HorizontalAlignment="Stretch" />
</StackPanel>

<ListView x:Name="MyListView" Margin="0,106,0,0">
    <ListView.View>
        <GridView>
            <GridViewColumn Header="Num" Width="70">
                <GridViewColumn.CellTemplate>
                    <DataTemplate>
                        <StackPanel Background="red" Orientation="Horizontal" HorizontalAlignment="Stretch">
                            <ComboBox HorizontalAlignment="Stretch" />
                        </StackPanel>
                    </DataTemplate>
                </GridViewColumn.CellTemplate>
            </GridViewColumn>
        </GridView>
    </ListView.View>
    <ListViewItem></ListViewItem>
</ListView>
Run Code Online (Sandbox Code Playgroud)

wpf combobox styles

11
推荐指数
1
解决办法
2万
查看次数

ComboBox强制崩溃(不是我的代码)

我从客户那里得到了下面的堆栈跟踪.我不知道如何重现这个.我的WPF应用程序有相当数量的ComboBoxes; 鉴于下面的堆栈跟踪,我不确定如何确定哪个ComboBox失败.有没有人见过这个?你能解释一下这个堆栈跟踪的内容吗?有任何想法吗?

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Controls.ComboBox.CoerceIsSelectionBoxHighlighted(Object o, Object value)
   at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
   at System.Windows.Controls.ComboBox.OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FocusWithinProperty.FireNotifications(UIElement uie, ContentElement ce, UIElement3D uie3D, Boolean oldValue)
   at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, …
Run Code Online (Sandbox Code Playgroud)

c# wpf combobox stack-trace

11
推荐指数
1
解决办法
3024
查看次数

获取ComboBoxItem的宽度

我已经将combobox绑定到string [].我没有清楚的组合框项目.但我想测量我的丢弃物品.如何在运行时获取组合框中的项目宽度.我需要这个来管理我的组合的宽度.

wpf layout combobox

2
推荐指数
1
解决办法
687
查看次数

标签 统计

combobox ×3

wpf ×3

c# ×1

layout ×1

stack-trace ×1

styles ×1