简体   繁体   English

如何在gridcontrol devexpress中添加popupcontainer编辑

[英]How to add popupcontainer edit in the gridcontrol devexpress

I am developing an application in WPF using MVVM design pattern. 我正在使用MVVM设计模式在WPF中开发应用程序。 So in one of my user controls I have a gridcontrol (devexpress). 因此,在我的一个用户控件中,我有一个gridcontrol(devexpress)。 This gridcontrol is bound to a datatable in my viewmodel class . 此gridcontrol绑定到我的viewmodel类中的数据表。 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. 现在,在注释列中,我希望一个弹出容器出现在我的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" 首先将以下内容添加到您的xaml命名空间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>使用GridColumn.EditSettings来编辑或查看编辑器中的单元格,如下所示

<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> . 另外,请使用ObservableCollection<T>

U :to have a custom control for a column use a DataTemplate U :要对列使用自定义控件,请使用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 U :对于您的最后评论,请使用带有ControlTemplate dxe:PopupBaseEditSettings

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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