开发者

Multicolumn display combobox within WPF datagrid

开发者 https://www.devze.com 2023-01-03 07:45 出处:网络
I wanted to create custom WPF datagrid control, which allows to have datagridcomboboxcolumn with multicolumn display on selection of combobox, how this can be 开发者_StackOverflow社区implemented. Plea

I wanted to create custom WPF datagrid control, which allows to have datagridcomboboxcolumn with multicolumn display on selection of combobox, how this can be 开发者_StackOverflow社区implemented. Please help

Thanks in advance Kartheesh.


I'm a little confused to exactly what your trying to ask, but possibly I think it's either of two things;

You want a multi-column display per column. For example you want two or more items per column displayed, e.g. two checkboxes, or textboxs, etc. The following code below displays two combox boxes binded to an object data provider

<dg:DataGridTemplateColumn  >
    <dg:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding item1}" />
                <TextBlock Text="{Binding item2}" />
            </StackPanel>
        </DataTemplate>
    </dg:DataGridTemplateColumn.CellTemplate>

    <dg:DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
            <ComboBox ItemsSource="{StaticResource mybiglist}"
                      SelectedValue="{Binding item1}"/>
            <ComboBox ItemsSource="{StaticResource mysecondbiglist}"
                      SelectedValue="{Binding item2}"/>
        </DataTemplate>
    </dg:DataGridTemplateColumn.CellEditingTemplate>
</dg:DataGridTemplateColumn>

Alternatively perhaps you want one or more columns per combo box, then this should help;

Multi-Column ComboBox in WPF A Simple Multicolumn Combo Box in WPF

0

精彩评论

暂无评论...
验证码 换一张
取 消