Home Forums WPF controls Xceed DataGrid for WPF adding combobox with xceed data grid

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23735 |

    Hi,

    I have used xceed datagrid in my project. And I am binding data with this
    grid using xmldataprovider. Now I want to add combo box in columns. Not able
    to add combobox . can you pleae help me how to add combo box and binding
    that combobox with xml.
    Can check the code I have used

    <Page x:Class=”DataGridApplication.GridApplication”>
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;

    Title=”GridApplication”>

    <!–using xml inside xmal to bind with grid–>
    <Page.Resources>

    <XmlDataProvider x:Key=”MyData” XPath=”Info”>

    <x:XData>
    <Info xmlns=””>
    <List>
    <Photo> No </Photo>
    <First> abc </First>
    <Last>xnm</Last>
    <BirthDate>1983</BirthDate>
    <Address>Bangalore</Address>
    <City>Bangalore</City>
    <Region>India</Region>
    <Country>India</Country>
    <PostalCode>56093</PostalCode>
    <HomePhone>3243234</HomePhone>
    <Notes>njh</Notes>
    </List>
    </Info>
    </x:XData>
    </XmlDataProvider>

    </Page.Resources>
    <xcdg:DataGridControl x:Name=”grid”
    CellEditorDisplayConditions=”None”
    EditTriggers=”None”
    ReadOnly=”True”
    ItemScrollingBehavior=”Immediate”
    NavigationBehavior=”RowOnly”
    ItemsSource=”{Binding Source={StaticResourceMyData} , XPath=List}”
    AutoCreateColumns=”False”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Photo”

    Title=”Photo”

    MinWidth=”65″

    MaxWidth=”65″

    DisplayMemberBinding=”{Binding XPath=Photo}” />

    <xcdg:Column FieldName=”First”

    Title=”First Name IsMainColumn=”True”
    MinWidth=”125″
    MaxWidth=”125″
    DisplayMemberBinding=”{Binding XPath=First}”
    >

    <xcdg:Column.CellEditor>

    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate> <ComboBox
    IsSynchronizedWithCurrentItem=”True” SelectedValue=”{Binding XPath=First,
    Mode=TwoWay}”>

    <ComboBoxItem
    Content=”Full” Width=”Auto” Height=”Auto”/>

    <ComboBoxItem
    Content=”Partial” Width=”Auto” Height=”Auto”/>

    <ComboBoxItem
    Content=”Low” Width=”Auto” Height=”Auto”/>

    </ComboBox>
    </DataTemplate>

    </xcdg:CellEditor.EditTemplate>
    <xcdg:CellEditor.ActivationGestures>
    <xcdg:KeyActivationGesture
    Key=”Right”/>
    <xcdg:KeyActivationGesture
    Key=”Left”/>
    </xcdg:CellEditor.ActivationGestures>
    </xcdg:CellEditor>

    </xcdg:Column.CellEditor>

    </xcdg:Column>

    <xcdg:Column FieldName=”Last”

    Title=”Last Name”

    MinWidth=”125″

    MaxWidth=”125″

    DisplayMemberBinding=”{Binding XPath=Last}”
    />

    <xcdg:Column FieldName=”BirthDate”

    Title=”Birth Date”

    MinWidth=”90″

    MaxWidth=”90″

    DisplayMemberBinding=”{Binding XPath=BirthDate}”/>

    <xcdg:Column FieldName=”Address”

    Title=”Address”

    MinWidth=”125″

    MaxWidth=”125″

    DisplayMemberBinding=”{Binding XPath=Address}”/>

    <xcdg:Column FieldName=”City”

    Title=”City”

    MinWidth=”125″

    MaxWidth=”125″
    DisplayMemberBinding=”{Binding XPath=City}” >

    </xcdg:Column>

    <xcdg:Column FieldName=”Region”

    Title=”Region”

    MinWidth=”125″

    MaxWidth=”125″

    DisplayMemberBinding=”{Binding XPath=Region}”/>

    <xcdg:Column FieldName=”Country”

    MinWidth=”125″

    MaxWidth=”125″

    DisplayMemberBinding=”{Binding XPath=Country}”/>

    <xcdg:Column FieldName=”PostalCode”

    Title=”Postal Code”

    MinWidth=”125″

    MaxWidth=”125″

    DisplayMemberBinding=”{Binding XPath=PostalCode}”/>

    <xcdg:Column FieldName=”HomePhone”

    Title=”Home Phone”

    Imported from legacy forums. Posted by kk (had 1866 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi ,

    Can anybody tell me how i can bind xml data with combobox used in Xceeddata grid column?

    is there any other way to bind data with combobox?

    thanks in advance

    kk

    Imported from legacy forums. Posted by kk (had 816 views)

    Xceed Support
    Member
    Post count: 5658

    Looking at your code, I can see several small problems:

    – You need to use the “CellEditorBinding” Markup extension to correctly bind your editor to the cell’s value.
    – For the editor to display, you will need to either have a CellEditorDisplayConditions or an EditTriggers which is not “None”.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 503 views)

    User (Old forums)
    Member
    Post count: 23064

    Its not working . can you please tell me in detail what changes should be done in my code?

    Thanks in advance
    kk

    Imported from legacy forums. Posted by kk (had 839 views)

    Xceed Support
    Member
    Post count: 5658

    <xcdg:DataGridControl x:Name=”grid”
    CellEditorDisplayConditions=”None”
    EditTriggers=”None” />

    Those 2 properties need NOT to be “None” so that the editor can be displayed… please refer to the documentation of those properties for a list of possible values.

    <ComboBox
    IsSynchronizedWithCurrentItem=”True” SelectedValue=”{Binding XPath=First,
    Mode=TwoWay}”>

    Instead of using a {Binding …} to bind the editor to the Cell, you need to use {xcdg:CellEditorBinding} … The syntax as you indicated is not supported, please refer to the documentation of CellEditorBindingExtension for details and to the “Advanced Concepts / Custom Cell Editors” topic in the documentation.

    If you have further problems, you will need to provide a more detailed explanation of what they are…

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4080 views)

    User (Old forums)
    Member
    Post count: 23064

     

    i want to add Combo box into Xceed Grid.please help me…

    Imported from legacy forums. Posted by jouhar (had 894 views)

    User (Old forums)
    Member
    Post count: 23064

    Can someone please answer this?

    Adding a ComboBox is sooo difficult. I have read and understand the Solid Foundation sample but I want to use a DataTable that is NOT in the Application.Current, it’s on the page. And do we have to create all this dictionary stuff – for EVERY type of combobox – just to display the meaningful value when not in edit mode! Gee whiz!

     

    Imported from legacy forums. Posted by Mark (had 849 views)

    User (Old forums)
    Member
    Post count: 23064

    UserControl.Resources of UserControl or Windows.Resources of Window

    <DataTemplate x:Key=”colReinstatementType”>
                <!—  Combobox will come HERE!! –>
    </DataTemplate>

     DataGrid

     <my1:DataGridControl 
                        Name=”myDataGrid”
                        AutoCreateColumns=”False”
                        NavigationBehavior=”RowOnly”                  
                        ItemsSource=”{Binding Source={StaticResource viewModel}, Path=MyData}” Margin=”12,135,9,69″ SelectionMode=”Single” ItemScrollingBehavior=”Deferred”>
                        <xcdg:DataGridControl.View>
                            <xcdg:TableView UseDefaultHeadersFooters=”False” ShowFixedColumnSplitter=”False”>
                                <xcdg:TableView.FixedHeaders>
                                    <DataTemplate>
                                        <xcdg:ColumnManagerRow />
                                    </DataTemplate>
                                </xcdg:TableView.FixedHeaders>
                            </xcdg:TableView>
                        </xcdg:DataGridControl.View>
                        <my1:DataGridControl.Columns>
                            <!– The column “Status” should be Unbound Column but it can’t be done with Xceed Datagrid so the bound column has to be used but it won’t be using in DataTemplate. Note: This is a trick. –>
                            <my1:Column FieldName=”Field1″ Title=”Status” Width=”50″ CellContentTemplate=”{StaticResource colReinstatementType}”>                           
                            </my1:Column>
                        </my1:DataGridControl.Columns>
                    </my1:DataGridControl>

     

    If you are following this way, you will be able to show any control in Grid Column. 

    But How can you get the reference of those controls inside datagrid?  I mean, how will you read the value of those controls that you put inside the Grid Column after the user is selecting?

    For this case, we can use Visual Tree Helper to loop through each and every DataGrid Row and get the reference of control. (This can be done)  But the problem comes here. Xceed Datagrid doesn’t show all rows on startup. That means, if the user scrolls the scrollbars then the rows will be created dynamically on the fly. So, we can’t get all rows. 🙁 Please read this post for more details about that problem. http://xceed.com/CS/forums/post/13798.aspx

     

    Imported from legacy forums. Posted by Michael (had 6277 views)

    Odi [Xceed]
    Spectator
    Post count: 426

    Reply in this thread:

    http://xceed.com/CS/forums/14001/ShowThread.aspx

    Imported from legacy forums. Posted by Odi [Xceed] (had 858 views)

    User (Old forums)
    Member
    Post count: 23064

    —————RESOURCES————

     <xcdg:CellEditor x:Key=”combobox”>
                <xcdg:CellEditor.EditTemplate>
                    <DataTemplate>
                        <ComboBox Width=”80″
                                          SelectValue=”{xcdg:CellEditorBinding}” >
                        </ComboBox>
                    </DataTemplate>
                </xcdg:CellEditor.EditTemplate>
            </xcdg:CellEditor>

    ————–DATAGRIDCONTROL——————

    <xcdg:DataGridControl Name=”DATAGRIDCONTROLname”
                                                ItemsSource=”{Binding Path=Table}” >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName=”FieldName”

                                          VisiblePosition=”” 

                                          CellEditor=”{StaticResource combobox}”/>          

    </xcdg:DataGridControl.Columns>

     

     

     

    Imported from legacy forums. Posted by rr (had 2073 views)

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.