zoukankan      html  css  js  c++  java
  • wpf LookUpEdit PopupContentTemplate

     1 <dxg:LookUpEdit
     2                 Name="searchLookUpEdit" 
     3                 HorizontalAlignment="Stretch" 
     4                 PopupHeight="500" 
     5                 PopupWidth="750" 
     6                 PopupMinHeight="100" 
     7                 PopupMinWidth="100" 
     8                 IsPopupAutoWidth="False" 
     9                 FilterCondition = "StartsWith" 
    10                 FindButtonPlacement = "Popup"
    11                 FindMode = "Always" 
    12                 ShowSizeGrip = "True" 
    13                 PopupContentTemplate="{StaticResource gridTemplate}" 
    14                 ItemsSource="{Binding Path=PeopleInfoArray}" 
    15                 AutoPopulateColumns="False" 
    16                 DisplayMember="Name" 
    17                 ValueMember="Id" 
    18                 >
    19             <dxg:LookUpEdit.StyleSettings>
    20                 <dxg:SearchLookUpEditStyleSettings />
    21             </dxg:LookUpEdit.StyleSettings>
    22         </dxg:LookUpEdit>
    LookUpEdit
     1  <ControlTemplate x:Key="popupContentTemplate">
     2                 <dxg:GridControl x:Name="PART_GridControl" AutoExpandAllGroups="True">
     3                     <dxg:GridControl.Columns>
     4                         <dxg:GridColumn FieldName="Id" />
     5                         <dxg:GridColumn FieldName="PId" />
     6                         <dxg:GridColumn FieldName="Name" />
     7                         <dxg:GridColumn FieldName="BirthDate" />
     8                         <dxg:GridColumn FieldName="Age" Width="60" FixedWidth="True" />
     9                     </dxg:GridControl.Columns>
    10                     <dxg:GridControl.View>
    11                         <dxg:TableView
    12                         Name="View" 
    13                         ShowGroupedColumns="True" 
    14                         AutoWidth="True" 
    15                         AllowPerPixelScrolling="True" 
    16                         ScrollAnimationDuration="0" 
    17                         ShowAutoFilterRow="True" 
    18                         ShowTotalSummary="True" 
    19                         IsSynchronizedWithCurrentItem="False">
    20                         </dxg:TableView>
    21                     </dxg:GridControl.View>
    22                 </dxg:GridControl>
    23             </ControlTemplate>
    ControlTemplate
     1 /// <summary>
     2     /// LookupControl.xaml 的交互逻辑
     3     /// </summary>
     4     public partial class LookupControl : Window
     5     {
     6         public LookupControl()
     7         {
     8             InitializeComponent();
     9             LookupControlViewModel viewModel = new LookupControlViewModel();
    10 
    11             this.DataContext = viewModel;
    12         }
    13     }
    LookupControl.xaml.cs
     1  /// <summary>
     2     /// Lookup 控件ViewModel
     3     /// </summary>
     4     public class LookupControlViewModel : DxslViewModelBase
     5     {
     6         /// <summary>
     7         /// 人员信息集合
     8         /// </summary>
     9         public ObservableCollection<PersonInfo> PeopleInfoArray { get; set; }
    10 
    11         public LookupControlViewModel()
    12         {
    13             PeopleInfoArray = Dxsl.InitDataBase.FackDataBaseLayer.GetPeopleFromDatabase();
    14         }
    15     }
    LookupControlViewModel
     1 public class FackDataBaseLayer
     2     {
     3         /// <summary>
     4         /// 获取人员信息
     5         /// </summary>
     6         /// <returns></returns>
     7         public static ObservableCollection<PersonInfo> GetPeopleFromDatabase()
     8         {
     9             //Simulate database extaction
    10             //For example from ADO DataSets or EF
    11             return new ObservableCollection<PersonInfo>
    12             {
    13                 new PersonInfo {Age=78 , Id= "1", PId="0", Address="北京市海淀区",  Name="王爷爷"  },
    14                 new PersonInfo {Age=55 , Id="2", PId="1",  Address="北京市海淀区",  Name="王父亲"  },
    15                 new PersonInfo {Age=26 , Id="3", PId="2",  Address="北京市海淀区",  Name="王一"  },
    16                 new PersonInfo {Age=22 , Id="4",PId="2",   Address="北京市海淀区",  Name="王二"  },
    17                 new PersonInfo {Age=25 , Id="5",PId="2",   Address="北京市海淀区",  Name="王三"  }
    18             };
    19         }
    20     }
    FackDataBaseLayer
     1  /// <summary>
     2     /// 人员信息
     3     /// </summary>
     4     public class PersonInfo : DxslModelBase
     5     {
     6         #region 字段
     7         private string _id;
     8         private string _pId;
     9         private string _name;
    10         private int _age;
    11         private string _address;
    12         #endregion
    13 
    14         #region 属性
    15         /// <summary>
    16         /// 自增Id
    17         /// </summary>
    18         public string Id
    19         {
    20             get { return _id; }
    21             set { _id = value; NotifyPropertyChanged("Id"); }
    22         }
    23         /// <summary>
    24         /// 父级Id
    25         /// </summary>
    26         public string PId
    27         {
    28             get { return _pId; }
    29             set { _pId = value; NotifyPropertyChanged("PId"); }
    30         }
    31         /// <summary>
    32         /// 姓名
    33         /// </summary>
    34         public string Name
    35         {
    36             get { return _name; }
    37             set { _name = value; NotifyPropertyChanged("Name"); }
    38         }
    39         /// <summary>
    40         /// 年龄
    41         /// </summary>
    42         public int Age
    43         {
    44             get { return _age; }
    45             set { _age = value; NotifyPropertyChanged("Age"); }
    46         }
    47         /// <summary>
    48         /// 地址
    49         /// </summary>
    50         public string Address
    51         {
    52             get { return _address; }
    53             set { _address = value; NotifyPropertyChanged("Address"); }
    54         }
    55         #endregion
    56 
    57         #region 构造函数
    58         public PersonInfo()
    59         {
    60 
    61         }
    62         #endregion
    63 
    64         #region 方法
    65 
    66         #endregion
    67     }
    PersonInfo
     1  /// <summary>
     2     /// Dxsl类model基类
     3     /// </summary>
     4     public class DxslModelBase : INotifyPropertyChanged
     5     {
     6         #region NotifyPropertyChanged
     7         public event PropertyChangedEventHandler PropertyChanged;
     8         /// <summary>
     9         /// 属性通知
    10         /// </summary>
    11         /// <param name="property">属性名称</param>
    12         public void NotifyPropertyChanged(string property)
    13         {
    14             if (this.PropertyChanged != null)
    15                 this.PropertyChanged(this, new PropertyChangedEventArgs(property));
    16         }
    17         #endregion
    18     }
    DxslModelBase
     1  public class DxslViewModelBase : INotifyPropertyChanged
     2     {
     3         #region NotifyPropertyChanged
     4         public event PropertyChangedEventHandler PropertyChanged;
     5         /// <summary>
     6         /// 属性通知
     7         /// </summary>
     8         /// <param name="property">属性名称</param>
     9         public void NotifyPropertyChanged(string property)
    10         {
    11             if (this.PropertyChanged != null)
    12                 this.PropertyChanged(this, new PropertyChangedEventArgs(property));
    13         }
    14         #endregion
    15     }
    DxslViewModelBase

  • 相关阅读:
    redis
    JSP
    Cookie&Session
    Servlet
    HTTP
    TomCat
    CSS
    XML
    JDBC
    Mysql(对表的操作)
  • 原文地址:https://www.cnblogs.com/-ShiL/p/Star201310290328.html
Copyright © 2011-2022 走看看