简体   繁体   中英

How to add popupcontainer edit in the gridcontrol devexpress

I am developing an application in WPF using MVVM design pattern. So in one of my user controls I have a gridcontrol (devexpress). This gridcontrol is bound to a datatable in my viewmodel class . For example the columns of my datatable are begin date , end date ,value, comments. Now in the column of comments I want a pop up container to appear in my gridcontrol. Is it possible to do that?

first add the following to your xaml namespaces xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"

You can use the GridColumn.EditSettings to edit or view the cell within an editor as the following inside your <dxg:GridControl>

<dxg:GridControl.Columns >
      <dxg:GridColumn FieldName="begindate">
               <dxg:GridColumn.EditSettings>
                    <dxe:DateEditSettings/>
               </dxg:GridColumn.EditSettings>
     </dxg:GridColumn>
      <dxg:GridColumn FieldName="enddate">
               <dxg:GridColumn.EditSettings>
                    <dxe:DateEditSettings/>
               </dxg:GridColumn.EditSettings>
     </dxg:GridColumn>
     <dxg:GridColumn FieldName="value"/>
     <dxg:GridColumn FieldName="comment">
               <dxg:GridColumn.EditSettings>
                    <dxe:MemoEditSettings/>
               </dxg:GridColumn.EditSettings>
     </dxg:GridColumn>
</dxg:GridControl.Columns>

And on a side note use a an ObservableCollection<T> .

U :to have a custom control for a column use a DataTemplate

<dxg:GridColumn FieldName="fieldname">
   <dxg:GridColumn.CellTemplate>
        <DataTemplate>
            <youcontrolnamespace:someCustomControl x:Name="PART_Editor"/>
        </DataTemplate>
    </dxg:GridColumn.CellTemplate>
</dxg:GridColumn>

U : for your last comment use dxe:PopupBaseEditSettings with a ControlTemplate

<dxg:GridColumn FieldName="fieldname">
      <dxg:GridColumn.EditSettings>
              <dxe:PopupBaseEditSettings>
                   <dxe:PopupBaseEditSettings.PopupContentTemplate>
                        <ControlTemplate>
                                  <!--Your Controls to popup here-->
                        </ControlTemplate>
                   </dxe:PopupBaseEditSettings.PopupContentTemplate>
              </dxe:PopupBaseEditSettings>
         </dxg:GridColumn.EditSettings>
</dxg:GridColumn>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM