当前位置: 首页>>代码示例>>C#>>正文


C# DatePicker.SetBinding方法代码示例

本文整理汇总了C#中System.Windows.Controls.DatePicker.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# DatePicker.SetBinding方法的具体用法?C# DatePicker.SetBinding怎么用?C# DatePicker.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.DatePicker的用法示例。


在下文中一共展示了DatePicker.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateEditingElement

 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     DatePicker picker = new DatePicker();
     picker.SetBinding(DatePicker.SelectedDateProperty, this.Binding);
     picker.IsDropDownOpen = true;
     return picker;
 }
开发者ID:jogibear9988,项目名称:SlGanttChart,代码行数:7,代码来源:GanttDateColumn.cs

示例2: DateTimeEditor

        public DateTimeEditor(WorkFrame frame)
            : base(frame)
        {
            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;
                        
            time = new TextBox();
            time.DataContext = this;
            time.Width = 64;
            var timeBinding = new Binding("Value");
            timeBinding.Mode = BindingMode.TwoWay;
            timeBinding.Converter = this;
            time.SetBinding(TextBox.TextProperty, timeBinding);
            
            date = new DatePicker();
            date.DataContext = this;
            var dateBinding = new Binding("Value");
            dateBinding.Converter = new DateConvert(time);
            dateBinding.Mode = BindingMode.TwoWay;
            date.SetBinding(DatePicker.SelectedDateProperty, dateBinding);

            Button now = new Button();
            now.Content = "当前时间";
            now.Click += (s, e) => Value = DateTime.Now;
            
            panel.Children.Add(date);
            panel.Children.Add(time);
            panel.Children.Add(now);

            Content = panel;
        }
开发者ID:liny4cn,项目名称:ComBoost,代码行数:31,代码来源:DateTimeEditor.cs

示例3: CreateView

 public FrameworkElement CreateView(PropertyInfo property)
 {
     var inputControl = new DatePicker();
     var binding = new Binding(property.Name);
     binding.Mode = BindingMode.TwoWay;
     inputControl.SetBinding(DatePicker.SelectedDateProperty, binding);
     return inputControl;
 }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:8,代码来源:DateConfigControl.cs

示例4: OnApplyTemplate

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            DatePicker = (DatePicker)GetTemplateChild("PART_DatePicker");
            DatePicker.SetBinding(DatePicker.SelectedDateProperty, new Binding { Source = this, Path = new PropertyPath(CurrentValueProperty), Mode = BindingMode.TwoWay });
            DatePicker.SelectedDateChanged += DatePicker_SelectedDateChanged;
        }
开发者ID:alexyjian,项目名称:ComBoost,代码行数:8,代码来源:DateEditor.cs

示例5: GenerateElement

 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem)
 {
     var element = new DatePicker
     {
         Style = Application.Current.Resources["DatePickerStyle"] as Style
     };
     element.SetBinding(DatePicker.SelectedDateProperty, Binding);
     return element;
 }
开发者ID:Dileriuml,项目名称:PostStore,代码行数:9,代码来源:DateTimeColumn.cs

示例6: GenerateEditingElement

 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     DatePicker picker = new DatePicker();
     picker.MinHeight = 16;
     picker.Padding = new Thickness(0);
     picker.BorderThickness = new Thickness(0);
     picker.SetBinding(DatePicker.SelectedDateProperty, Binding);
     picker.IsDropDownOpen = true;
     return picker;
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:10,代码来源:DataGridDateColumn.cs

示例7: GenerateEditingElement

 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
 {
     var dp = new DatePicker {VerticalAlignment = VerticalAlignment.Stretch};
     if (DateFormat != null)
     {
         IValueConverter dtc = new DateTimeConverter();
         Binding.Converter = dtc;
         Binding.ConverterParameter = DateFormat;
     }
     dp.SetBinding(DatePicker.SelectedDateProperty, Binding);
     return dp;
 }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:12,代码来源:DataGridColumns.cs

示例8: CreateControl

        public override FrameworkElement CreateControl(FormItemContext context)
        {
            DatePicker picker = new DatePicker();

            var binding = new Binding(context.PropertyInfo.Name)
            {
                Mode = BindingMode.TwoWay,
            };
            binding.ValidationRules.Add(new AnnotationValidationRule(context.PropertyInfo));
            picker.SetBinding(DatePicker.SelectedDateProperty, binding);
            CustomValidation.SetValidationProperty(picker, DatePicker.SelectedDateProperty);
            StyleHelper.ApplyStyle(picker, FormControlConstrants.EDIT_DATE_STYLE);
            return picker;
        }
开发者ID:mogliang,项目名称:Generic-WPF-Form-Controls,代码行数:14,代码来源:DatePickerSink.cs

示例9: DateEditor

        public DateEditor(WorkFrame frame)
            : base(frame)
        {
            StackPanel panel = new StackPanel();
            panel.Orientation = Orientation.Horizontal;

            DatePicker date = new DatePicker();
            date.Width = 120;
            date.DataContext = this;
            var binding = new Binding("Value");
            binding.Mode = BindingMode.TwoWay;
            date.SetBinding(DatePicker.SelectedDateProperty, binding);

            panel.Children.Add(date);

            Content = panel;
        }
开发者ID:liny4cn,项目名称:ComBoost,代码行数:17,代码来源:DateEditor.cs

示例10: CreateDateField

        private static ModelPropertyUiInfo CreateDateField(Grid grid,
            DisplayPropertyInfo property,
            String bindingPath,
            Style style,
            int row,
            int column)
        {
            Label labelElement = CreateLabel(property, row, column);

            DatePicker control = new DatePicker
            {
                Name = "datePicker" + property.PropertyName
            };
            if (style != null)
            {
                control.Style = style;
            }

            Binding binding = ModelUiCreatorHelper.CreateBinding(property, bindingPath);
            control.SetBinding(DatePicker.SelectedDateProperty, binding);

            if (property.IsReadOnly)
            {
                control.IsEnabled = false;
            }

            Grid.SetRow(control, row);
            Grid.SetColumn(control, checked(column + 1));

            grid.Children.Add(labelElement);
            grid.Children.Add(control);

            // return
            ModelPropertyUiInfo elememtsInfo = new ModelPropertyUiInfo(property);
            elememtsInfo.Label = labelElement;
            elememtsInfo.Content = control;
            return elememtsInfo;
        }
开发者ID:snyang,项目名称:AppGene,代码行数:38,代码来源:ModelUiElementCreator.cs

示例11: Init

        private void Init()
        {
            var detail = this;
            foreach (var propertyInfo in TypeObj.GetProperties(BindingFlags.DeclaredOnly
                    | BindingFlags.Public | BindingFlags.Instance))
            {
                detail.Children.Add(new TextBlock { Text = SeparateCapitalWords(propertyInfo.Name) });
                FrameworkElement element;
                var binding = new Binding(propertyInfo.Name);
                if (propertyInfo.CanWrite)
                {
                    binding.Mode = BindingMode.TwoWay;
                    if (typeof(DateTime).IsAssignableFrom(propertyInfo.PropertyType))
                    {
                        var dtp = new DatePicker();
                        dtp.SetBinding(DatePicker.SelectedDateProperty, binding);
                        element = new CoverControl { Control = dtp, Name = propertyInfo.Name };
                    }
                    else if (typeof(Enum).IsAssignableFrom(propertyInfo.PropertyType))
                    {
                        var cb = new ComboBox();
                        cb.SetBinding(Selector.SelectedItemProperty, binding);
                        var propertyInfo1 = propertyInfo;
                        Utilities.FillEnums(cb, propertyInfo1.PropertyType);
                        element = new CoverControl { Control = cb, Name = propertyInfo.Name };
                    }
                    else if (typeof(Persistent).IsAssignableFrom(propertyInfo.PropertyType))
                    {
                        var cb = new ComboBox();
                        cb.SetBinding(Selector.SelectedItemProperty, binding);
                        var propertyInfo1 = propertyInfo;
                        dropdowns[cb] = propertyInfo1.PropertyType;
                        element = new CoverControl { Control = cb, Name = propertyInfo.Name };
                    }
                    else
                    {
                        var tb = new TextBox();
                        tb.SetBinding(TextBox.TextProperty, binding);
                        element = new CoverControl { Control = tb, Name = propertyInfo.Name };
                    }
                }
                else
                {
                    binding.Mode = BindingMode.OneWay;
                    var tb = new TextBlock();
                    tb.SetBinding(TextBlock.TextProperty, binding);
                    element = tb;
                }
                detail.Children.Add(element);
            }

            var grid = new Grid { Margin = new Thickness(0, 50, 0, 0) };
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            var b = new Button { Content = "Delete" };
            b.Click += DeleteOnClick;
            b.SetValue(Grid.ColumnProperty, 2);
            grid.Children.Add(b);

            detail.Children.Add(grid);
        }
开发者ID:yan122725529,项目名称:TripRobot.Crawler,代码行数:63,代码来源:DetailPanel.cs

示例12: CreateControl

        private FrameworkElement CreateControl(DataFieldItem dfItem)
        {
            ControlType cType = dfItem.CType;
            Binding binding = new Binding();
            binding.Path = new PropertyPath(dfItem.PropertyName);
            binding.Mode = BindingMode.TwoWay;
            binding.Converter = new CommonConvert(dfItem);
            
            FrameworkElement c = null;
            switch (cType)
            {
                case ControlType.Label:
                    TextBlock tbx = new TextBlock();
                    
                    if (dfItem.ReferenceDataInfo != null)
                    {
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember + ".Text");
                    }
                    tbx.SetBinding(TextBlock.TextProperty, binding);
                    
                    c = tbx;
                    break;
                case ControlType.TextBox:
                    TextBox tb = new TextBox();
                    tb.SetBinding(TextBox.TextProperty, binding);
                    tb.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
                    tb.MaxLength = dfItem.MaxLength;
                    if ( dfItem.DataType.ToLower() == "decimal" || dfItem.DataType.ToLower() == "datetime")
                    {
                        tb.TextAlignment = TextAlignment.Right;
                    }
                    c = tb;
                    break;
                case ControlType.Combobox:

                    ComboBox cbb = new ComboBox();

                    if (dfItem.ReferenceDataInfo != null)
                    {
                        cbb.ItemsSource = this.GetItemSource(dfItem.ReferenceDataInfo.Type);
                        cbb.DisplayMemberPath = "Text";
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
                    }

                    cbb.SetBinding(ComboBox.SelectedItemProperty, binding);
                    cbb.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                   
                    c = cbb;
                    
                    break;
                case ControlType.LookUp:
                    FBLookUp lookUp = new FBLookUp();
                    lookUp.OperationType = this.OperationType;
                    lookUp.DisplayMemberPath = dfItem.PropertyName;
                    if (dfItem.ReferenceDataInfo != null)
                    {
                        lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.ReferencedMember + ".Text";
                        if (!string.IsNullOrEmpty(dfItem.ReferenceDataInfo.TextPath))
                        {
                            lookUp.DisplayMemberPath = dfItem.ReferenceDataInfo.TextPath;
                        }
                        lookUp.LookUpType = dfItem.ReferenceDataInfo.Type;
                        binding.Path = new PropertyPath(dfItem.ReferenceDataInfo.ReferencedMember);
                    }
                    lookUp.SetBinding(LookUp.SelectItemProperty, binding);
                    lookUp.ReferencedDataInfo = dfItem.ReferenceDataInfo;
                    lookUp.Parameters = dfItem.ReferenceDataInfo.Parameters;
                    lookUp.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);
                    c = lookUp;
                    break;
                case ControlType.Remark:
                    TextBox tbRemark = new TextBox();
                    tbRemark.AcceptsReturn = true;
                    tbRemark.TextWrapping = TextWrapping.Wrap;
                    //tbRemark.Height = 66;
                    //tbRemark.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
                    //tbRemark.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                    tbRemark.SetBinding(TextBox.TextProperty, binding);
                    c = tbRemark;

                    tbRemark.IsReadOnly = (IsReadOnly || dfItem.IsReadOnly);

                    tbRemark.MaxLength = dfItem.MaxLength;
                    
                    break;
                case ControlType.DatePicker:
                    DatePicker datePicker = new DatePicker();
                    datePicker.SelectedDateFormat = DatePickerFormat.Short;
                    datePicker.SetBinding(DatePicker.SelectedDateProperty, binding);                    
                    c = datePicker;
                    datePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                    break;
                case ControlType.DateTimePicker:
                    DateTimePicker dateTimePicker = new DateTimePicker();
                    dateTimePicker.SetBinding(DateTimePicker.ValueProperty, binding);
                    c = dateTimePicker;
                    dateTimePicker.IsEnabled = !(IsReadOnly || dfItem.IsReadOnly);
                    break;
                // Add By LVCHAO 2011.01.30 14:46
                case ControlType.HyperlinkButton:
//.........这里部分代码省略.........
开发者ID:JuRogn,项目名称:OA,代码行数:101,代码来源:FieldForm.xaml.cs

示例13: GetControlByType

	    private Control GetControlByType(RdlType.ReportParameterType parameter, Binding paramValueBind)
	    {
            Control paramControl = new TextBox();
	        BindingExpressionBase expr = null;

	        if (parameter.HasValidValues)
	        {
	            paramControl = new ComboBox()
	            {
	                ItemsSource = viewModel.ReportType.GetReportParameterValidValues(parameter.Name),
	                SelectedValuePath = "Value",
	                DisplayMemberPath = "Key"
	            };

	            expr = paramControl.SetBinding(ComboBox.SelectedValueProperty, paramValueBind);
	        }
	        else
	        {

	            switch (parameter.DataType)
	            {
	                case RdlType.ReportParameterType.DataTypeEnum.DateTime:
	                    paramControl = new DatePicker();
	                    expr = paramControl.SetBinding(DatePicker.SelectedDateProperty, paramValueBind);
	                    break;

	                case RdlType.ReportParameterType.DataTypeEnum.Boolean:
	                    paramControl = new CheckBox();
	                    expr = paramControl.SetBinding(CheckBox.IsCheckedProperty, paramValueBind);
	                    break;

	                case RdlType.ReportParameterType.DataTypeEnum.Integer:
	                    paramControl = new IntegerUpDown();
	                    expr = paramControl.SetBinding(IntegerUpDown.ValueProperty, paramValueBind);
	                    break;

	                case RdlType.ReportParameterType.DataTypeEnum.Float:
	                    paramControl = new DecimalUpDown();
	                    expr = paramControl.SetBinding(DecimalUpDown.ValueProperty, paramValueBind);
	                    break;

	                default:
	                    expr = paramControl.SetBinding(TextBox.TextProperty, paramValueBind);
	                    break;
	            }
	        }
           
	        viewModel.ClearParameters += (sender, args) => expr.UpdateTarget();
	        return paramControl;
	    }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:50,代码来源:ReportView.xaml.cs

示例14: CreateDateTimeControl

 /// <summary>
 /// Creates the date time control.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <returns>
 /// The control.
 /// </returns>
 protected virtual FrameworkElement CreateDateTimeControl(PropertyItem property)
 {
     var c = new DatePicker();
     c.SetBinding(DatePicker.SelectedDateProperty, property.CreateBinding());
     return c;
 }
开发者ID:hasol81,项目名称:PropertyTools,代码行数:13,代码来源:DefaultPropertyControlFactory.cs

示例15: SetDatePickerBinding

		public static Binding SetDatePickerBinding (DataRowView AktuellView, DatePicker ControlToFill, String DataColumnName)
			{
			Binding DateBinding = new Binding (DataColumnName);
			DateBinding.Source = AktuellView;
			ControlToFill.SetBinding (DatePicker.SelectedDateProperty, DateBinding);
			return DateBinding;
			}
开发者ID:heinzsack,项目名称:DEV,代码行数:7,代码来源:ConnectorSupport.cs


注:本文中的System.Windows.Controls.DatePicker.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。