Beispiel #1
0
        public static XElementString GetDataGridElement(List <GridItem> items)
        {
            XElementString gridXCs = new XElementString("data:DataGrid.Columns");

            items.ForEach(item =>
            {
                XElementString gridXColumn = new XElementString("data:DataGridTextColumn",
                                                                new XAttributeString("Header", item.PropertyDisplayName),
                                                                new XAttributeString("Width", item.Width.ToString())
                                                                );
                if (!string.IsNullOrEmpty(item.PropertyName))
                {
                    gridXColumn.Add(new XAttributeString("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName + "}"));
                }

                //XElement gridXColumn = new XElement(data + "DataGridTextColumn",
                //    new XAttribute("Header", item.PropertyDisplayName),
                //    new XAttribute("Width", item.Width.ToString()),
                //    new XAttribute("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName +"}")
                //    );
                gridXCs.Add(gridXColumn);
            });
            //
            XElementString gridX = new XElementString("data:DataGrid", new XAttributeString("AutoGenerateColumns", "false"));

            gridX.Add(gridXCs);

            return(gridX);
        }
Beispiel #2
0
        public static XElementString GetDataGridElement(List<GridItem> items)
        {
            XElementString gridXCs = new XElementString("data:DataGrid.Columns");
           
            items.ForEach(item =>
            {
                XElementString gridXColumn = new XElementString("data:DataGridTextColumn",
                                     new XAttributeString("Header", item.PropertyDisplayName),
                                     new XAttributeString("Width", item.Width.ToString())
                                     );
                if (! string.IsNullOrEmpty(item.PropertyName))
                {
                   gridXColumn.Add( new XAttributeString("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName + "}"));
                }

                //XElement gridXColumn = new XElement(data + "DataGridTextColumn", 
                //    new XAttribute("Header", item.PropertyDisplayName),
                //    new XAttribute("Width", item.Width.ToString()),
                //    new XAttribute("Binding", "{Binding Mode=TwoWay, Path=" + item.PropertyName +"}")
                //    );
                gridXCs.Add(gridXColumn);
            });
             //  
            XElementString gridX = new XElementString("data:DataGrid", new XAttributeString("AutoGenerateColumns", "false"));
            gridX.Add(gridXCs);

            return gridX;
        }
Beispiel #3
0
        public static DataTemplate GetDataTemplate(XElementString xDataTemplate)
        {
            XElementString xRoot = GetEmptyDataTemplate();
            xRoot.Add(xDataTemplate);

            DataTemplate dataTemplate = XamlReader.Load(xRoot.ToString()) as DataTemplate;
            return dataTemplate;
        }
Beispiel #4
0
        public static DataTemplate GetDataTemplate(XElementString xDataTemplate)
        {
            XElementString xRoot = GetEmptyDataTemplate();

            xRoot.Add(xDataTemplate);

            DataTemplate dataTemplate = XamlReader.Load(xRoot.ToString()) as DataTemplate;

            return(dataTemplate);
        }
Beispiel #5
0
        public static XElementString GetEmptyDataTemplate()
        {
            XElementString xDataTemplate =
                new XElementString("DataTemplate",
                                   new XAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"),
                                   new XAttributeString("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"),
                                   new XAttributeString("xmlns:smtx", "clr-namespace:SMT.SaaS.FrameworkUI;assembly=SMT.SaaS.FrameworkUI"),
                                   new XAttributeString("xmlns:data", "clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data")
                                   );

            return(xDataTemplate);
        }
Beispiel #6
0
        public static XElementString GetEmptyDataTemplate()
        {

            XElementString xDataTemplate =
           new XElementString("DataTemplate",
               new XAttributeString("xmlns", "http://schemas.microsoft.com/winfx/2006/xaml/presentation"),
               new XAttributeString("xmlns:x", "http://schemas.microsoft.com/winfx/2006/xaml"),
               new XAttributeString("xmlns:smtx", "clr-namespace:SMT.SaaS.FrameworkUI;assembly=SMT.SaaS.FrameworkUI"),
               new XAttributeString("xmlns:data", "clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data")
               );

            return xDataTemplate;
        }
Beispiel #7
0
 public void Add(XElementString xObjectString)
 {
     XElementStrings.Add(xObjectString);
 }
Beispiel #8
0
        public static DataTemplate GetEmptyGrid()
        {

            XElementString xGrid = new XElementString("Grid");
            return GetDataTemplate(xGrid);
        }
Beispiel #9
0
        public static DataTemplate GetEmptyGrid()
        {
            XElementString xGrid = new XElementString("Grid");

            return(GetDataTemplate(xGrid));
        }
Beispiel #10
0
        public static DataTemplate GetDataGrid(List <GridItem> items)
        {
            XElementString gridX = GetDataGridElement(items);

            return(GetDataTemplate(gridX));
        }
Beispiel #11
0
        public void InitControl(OperationTypes operationType)
        {
            columnHeaderStyle = (Style)Application.Current.Resources["DataGridColumnHeaderStyle"];
            this.Style = (Style)Application.Current.Resources["DataGridStyle"];
            this.RowStyle = (Style)Application.Current.Resources["DataGridRowStyle"];
            //this.ColumnHeaderStyle = 
            this.Columns.Clear();
            for (int i = 0; i < GridItems.Count; i++)
            {
                DataGridColumn dgtc = GetDataGridColumn(GridItems[i]);
                string toolTipText = GridItems[i].TipText;


                dgtc.Header = GridItems[i].PropertyDisplayName;
                dgtc.Width = new DataGridLength(GridItems[i].Width);
                
                dgtc.SortMemberPath = GridItems[i].PropertyName;
                dgtc.CanUserSort = true;
                
                // 可写背景色
                if (!GridItems[i].IsReadOnly && (operationType != OperationTypes.Browse && operationType != OperationTypes.Audit))
                {
                    dgtc.CellStyle = writtableStyle;
                    
                    dgtc.IsReadOnly = false;
                }
                else
                {
                    dgtc.IsReadOnly = true;
                }
                this.Columns.Add(dgtc);

                var styleHeader = this.columnHeaderStyle;
                if (toolTipText != null)
                {
                    //<TextBlock Margin="3 2 0 2"  Foreground="{StaticResource HeaderBackgroundfontColor1}" x:Name="ContentFontColor">
                    //</TextBlock>

                    XElementString gridXCs = new XElementString("TextBlock",
                        new XAttributeString("Margin", "3 2 0 2"),
                        new XAttributeString("Foreground", "{StaticResource HeaderBackgroundfontColor1}"),
                        new XAttributeString("x:Name", "ContentFontColor"),
                        new XAttributeString("Text", "{Binding  Converter={StaticResource GridHeaderConverter}, RelativeSource={RelativeSource TemplatedParent}}"),
                        new XAttributeString("ToolTipService.ToolTip", toolTipText)
                        );

                    var dtHeadTextBlockTemplate = DataTemplateHelper.GetDataTemplate(gridXCs);

                    styleHeader = styleHeader.Copy();
                    styleHeader.SetStyle(DataGridColumnHeader.ContentTemplateProperty, dtHeadTextBlockTemplate);
                }
                dgtc.HeaderStyle = styleHeader;
                
            }
        }
Beispiel #12
0
        private DataGridColumn GetDataGridColumn(GridItem gItem)
        {
            Binding bding = new Binding();
            if (!string.IsNullOrEmpty(gItem.PropertyName))
            {
                bding.Mode = BindingMode.TwoWay;
                bding.Path = new PropertyPath(gItem.PropertyName);
                if (gItem.ReferenceDataInfo != null)
                {
                    IValueConverter converter = CommonFunction.GetIValueConverter(gItem.ReferenceDataInfo.Type);
                    bding.Converter = converter;
                }
                else if (gItem.PropertyName.Contains("MONEY"))
                {
                    IValueConverter converter = new CurrencyConverter();
                    bding.Converter = converter;
                }
                else
                {
                    IValueConverter converter = new CommonConvert(gItem);
                    bding.Converter = converter;
                }
                
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("");
            }

            DataGridColumn dgc = null;
            switch (gItem.CType)
            {
                case ControlType.CheckBox :
                    DataGridCheckBoxColumn dgcc = new DataGridCheckBoxColumn();
                    dgcc.IsThreeState = false;
                    dgcc.Binding = bding;
                    dgc = dgcc;
                    break;
                case ControlType.Label :
                    if (gItem.ReferenceDataInfo != null)
                    {
                        DataGridReferenceColumn dgrc = new DataGridReferenceColumn();
                        dgrc.Binding = bding;
                        dgrc.DisplayMemberPath = "Text";
                        
                        dgc = dgrc;

                    }
                    else
                    {
                        DataGridTextColumn dgtc = new MyDataGridTextColumn(gItem);
                        dgtc.Binding = bding;
                        dgc = dgtc;
                    }
                    break;

                case ControlType.Combobox :

                    DataGridComboBoxColumn dgcbc = new DataGridComboBoxColumn();
                    if (gItem.ReferenceDataInfo != null)
                    {
                        IList<ITextValueItem> list = DataCore.GetRefData(gItem.ReferenceDataInfo.Type);
                        dgcbc.ItemsSource = list;
                    }
                    dgcbc.DisplayMemberPath = "Text";
                    dgcbc.Binding = bding;

                    dgc = dgcbc;
                    break;

                case ControlType.TreeViewItem :
                    DataGridIconColumn dgtvic = new DataGridIconColumn();
                    dgtvic.Binding = bding;
                    dgc = dgtvic;
                    break;
                case ControlType.Templete:
                    
                     //"<StackPanel Orientation="Horizontal"><smtx:ImageButton x:Name="myDelete" Click="Delete_Click"/></StackPanel>"
                    var gridXCs = new XElementString("StackPanel",new XAttributeString("Orientation", "Horizontal"));
                  
                    DataGridTemplateColumn dtc = new DataGridTemplateColumn();
                    dtc.CellTemplate = DataTemplateHelper.GetDataTemplate(gridXCs);
                    dgc = dtc;
                    break;
            }

            return dgc;
        }
Beispiel #13
0
 public void Add(XElementString xObjectString)
 {
     XElementStrings.Add(xObjectString);
 }