zoukankan      html  css  js  c++  java
  • FrameworkElementFactory中的SetBinding与SetValue

    public static Microsoft.Windows.Controls.DataGridColumn CreateDateColumn(string path, string header)
            {
                ExtendedDataGridTemplateColumn<Microsoft.Windows.Controls.DatePicker> gridTemplateColumn =
                    new ExtendedDataGridTemplateColumn<Microsoft.Windows.Controls.DatePicker>();
                DataTemplate dataTemplate = new DataTemplate();
                FrameworkElementFactory frameworkElementFactory =
                    new FrameworkElementFactory(typeof(Microsoft.Windows.Controls.DatePicker));
                frameworkElementFactory.SetBinding(Microsoft.Windows.Controls.DatePicker.SelectedDateProperty, new Binding()
                {
                    Path = new PropertyPath(path),
                    Mode = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                });
                dataTemplate.VisualTree = frameworkElementFactory;
                gridTemplateColumn.MinWidth = 100.0;
                gridTemplateColumn.Width = 140.0;
                gridTemplateColumn.Header = header;
                gridTemplateColumn.CellEditingTemplate = dataTemplate;
                gridTemplateColumn.CellTemplate = createDataTimeTextBolckCellTemplate(path);
                return gridTemplateColumn;
            }
    
    
    private static DataTemplate createDataTimeTextBolckCellTemplate(string path)
            {
                DataTemplate dataTemplate = new DataTemplate();
                FrameworkElementFactory frameworkElementFactory = new FrameworkElementFactory(typeof(TextBlock));
                Binding binding = new Binding();
                binding.Path = new PropertyPath(path);
                
                binding.StringFormat = "yyyy-MM-dd";
                
                binding.Mode = BindingMode.OneWay;
                frameworkElementFactory.SetBinding(TextBlock.TextProperty, binding);
                frameworkElementFactory.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);
                frameworkElementFactory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                
                dataTemplate.VisualTree = frameworkElementFactory;
                return dataTemplate;
            }
    
  • 相关阅读:
    pikachu——Unsafe Filedownload Fileupload(不安全的文件下载和上传)
    pikachu——Files Inclusion(文件包含漏洞)
    pikachu——RCE
    pikachu——SQL注入
    pikachu——XSS(跨网站脚本漏洞)
    pikachu——CSRF
    pikachu——暴力破解
    GCD 信号量 dispatch_semaphore_t
    【转】iOS 9 Storyboard 教程(一上)
    一个大小为N的数组,里面是N个整数,怎样去除重复的数
  • 原文地址:https://www.cnblogs.com/sesametech-netcore/p/13848019.html
Copyright © 2011-2022 走看看