WPF GRID里的下拉框如何默认显示

px372265205 2016-01-28 03:40:06
我的列表中的下拉框的出现是被textbox中落入焦点才激发的,如何默认就显示出下拉框呢
默认是这样的
点击后是这样的
如何让他默认就显示下拉框呢
<DataGridComboBoxColumn  Header="数量"  TextBinding="{Binding CurrentStyle}"  MinWidth="100"  >
<DataGridComboBoxColumn.ElementStyle >
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding MarkupStyle}" />
<Setter Property="SelectedValue" Value="{Binding ApplicableParty}" />
<Setter Property="SelectedValuePath" Value="{Binding CurrentParty}" />
<Setter Property="DisplayMemberPath" Value="{Binding Style}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
<DataGridComboBoxColumn.EditingElementStyle >
<Style TargetType="ComboBox" >
<Setter Property="ItemsSource" Value="{Binding MarkupStyle}" />
<Setter Property="SelectedValue" Value="{Binding ApplicableParty}" />
<Setter Property="SelectedValuePath" Value="{Binding CurrentParty}" />
<Setter Property="DisplayMemberPath" Value="{Binding Style}" />
</Style>
</DataGridComboBoxColumn.EditingElementStyle >
...全文
1402 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
wjq 2016-02-06
  • 打赏
  • 举报
回复
你应该用DataGrid的模板列(DataGridTemplateColumn ),如果你需要一直显示编辑控件那么直接在CellTemplate 模板里添加ComboBox即可。不必用Style去设置控件,直接在CellTemplate 里添加<DataTemplate><Gird><ComboBox /></Grid></DataTemplate>即可,如果设置默认值,根据你给ComboBox绑定的列表类型来决定,通常直接绑定SelectedItem即可。
  • 打赏
  • 举报
回复
引用 8 楼 px372265205 的回复:
[quote=引用 7 楼 duanzi_peng 的回复:]
-》总是显示 不会,combobox里包含 Popup下拉控件,只有触发点击的时候才会弹出。一整列的 combobox 不会全都默认下拉。
px372265205 2016-02-01
  • 打赏
  • 举报
回复
[quote=引用 7 楼 duanzi_peng 的回复:]

  • 打赏
  • 举报
回复

例如:
px372265205 2016-02-01
  • 打赏
  • 举报
回复
引用 5 楼 duanzi_peng 的回复:
引用 3 楼 px372265205 的回复:
[quote=引用 1 楼 duanzi_peng 的回复:] 设置SelectedIndex属性
这个怎么用
自己不用去 网上查询吗[/quote] 查了啊,不好使啊,所以我才问怎么用,是不是我用错了。
  • 打赏
  • 举报
回复
引用 3 楼 px372265205 的回复:
引用 1 楼 duanzi_peng 的回复:
设置SelectedIndex属性
这个怎么用
自己不用去 网上查询吗
  • 打赏
  • 举报
回复
设置SelectedIndex属性
px372265205 2016-01-29
  • 打赏
  • 举报
回复
private void BagInfo_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {

            if (e.AddedCells.Count == 0)
                return;
            var currentCell = e.AddedCells[0];
            if (currentCell.Column == BagInfo.Columns[5])   //Columns[]从0开始  我这的ComboBox在第六列  所以为5   
            {
                BagInfo.BeginEdit();    //  进入编辑模式  这样单击一次就可以选择ComboBox里面的值了   
            }
        }
写了个这个点一次能出来了,如何能不点也出来啊
px372265205 2016-01-29
  • 打赏
  • 举报
回复
这个属性加到Grid里面么?,不好使啊。
px372265205 2016-01-29
  • 打赏
  • 举报
回复
引用 1 楼 duanzi_peng 的回复:
设置SelectedIndex属性
这个怎么用

8,756

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧