public override void OnApplyTemplate() #endif { base.OnApplyTemplate(); if (InputBox != null) { #if WINDOWS_STORE || WINDOWS_PHONE_APP var binding = new Windows.UI.Xaml.Data.Binding(); #elif WINDOWS_PHONE var binding = new System.Windows.Data.Binding(); #endif binding.Source = InputBox; binding.Path = new PropertyPath("Text"); SetBinding(ValueProperty, binding); TextBinding.SetUpdateSourceOnChange(InputBox, true); InputBox.TextChanged -= InputBoxTextChanged; InputBox.SelectionChanged -= InputBoxSelectionChanged; // manually adding // GetBindingExpression doesn't seem to respect TemplateBinding // so TextBoxBinding's code doesn't fire InputBox.TextChanged += InputBoxTextChanged; InputBox.SelectionChanged += InputBoxSelectionChanged; } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); InputBox = GetTemplateChild(InputBoxName) as TextBox; if (InputBox != null) { // manually adding // GetBindingExpression doesn't seem to respect TemplateBinding // so TextBoxBinding's code doesn't fire var binding = new System.Windows.Data.Binding { Source = InputBox, Path = new PropertyPath("Text"), }; SetBinding(ValueProperty, binding); HookUpEventForIsSubmitOnEnterKey(); if (!DesignerProperties.IsInDesignTool) ThreadPool.QueueUserWorkItem(DelayInputSelect); } }
private void lvServices_GridViewColumnHeader_Click(object sender, RoutedEventArgs e)//sort { //ref:WPF中对ListView排序 //http://www.cnblogs.com/huihui0630/archive/2008/10/22/1317140.html if (e.OriginalSource is GridViewColumnHeader) { //Get clicked column GridViewColumn clickedColumn = (e.OriginalSource as GridViewColumnHeader).Column; if (clickedColumn != null) { string bindingProperty; //Get binding property of clicked column if (clickedColumn.DisplayMemberBinding is System.Windows.Data.Binding) { bindingProperty = (clickedColumn.DisplayMemberBinding as System.Windows.Data.Binding).Path.Path; } else//multibinding for Output Tile Count column { System.Windows.Data.Binding binding = (clickedColumn.DisplayMemberBinding as System.Windows.Data.MultiBinding).Bindings[0] as System.Windows.Data.Binding; bindingProperty = binding.Path.Path; } SortDescriptionCollection sdc = lvServices.Items.SortDescriptions; ListSortDirection sortDirection = ListSortDirection.Ascending; if (sdc.Count > 0) { SortDescription sd = sdc[0]; sortDirection = (ListSortDirection)((((int)sd.Direction) + 1) % 2); sdc.Clear(); } sdc.Add(new SortDescription(bindingProperty, sortDirection)); } } }
private void CreateUserContextMenu() { UserContextMenu = new ContextMenu(); var whisper = new MenuItem(); whisper.Header = "Whisper"; whisper.Click += WhisperOnClick; UserContextMenu.Items.Add(whisper); var addFriend = new MenuItem(); addFriend.Header = "Add Friend"; addFriend.Click += AddFriendOnClick; UserContextMenu.Items.Add(addFriend); var ban = new MenuItem(); ban.Header = "Ban"; ban.Click += BanOnClick; UserContextMenu.Items.Add(ban); var binding = new System.Windows.Data.Binding(); binding.Mode = System.Windows.Data.BindingMode.OneWay; binding.Converter = new BooleanToVisibilityConverter(); binding.Source = BanMenuVisible; ban.SetBinding(VisibilityProperty, binding); }
public MenuCommand(UIElement inputBindingOwner, Codon codon, object caller, string activationMethod, IReadOnlyCollection <ICondition> conditions) : base(codon, caller, conditions) { ActivationMethod = activationMethod; Command = CommandWrapper.CreateLazyCommand(codon, conditions); //this.CommandParameter = caller; if ("true" == codon.Properties["usedatacontext"]?.ToLowerInvariant()) { _useDataContext = true; var myBinding = new System.Windows.Data.Binding(nameof(DataContext)) { Source = this }; SetBinding(System.Windows.Controls.MenuItem.CommandParameterProperty, myBinding); // this.DataContextChanged += (s,e) => UpdateStatus(); // we can abstain from using this as long as the workbench calls UpdateStatus for all menus (especially the workbench's context menu) } else { CommandParameter = caller; } if (!string.IsNullOrEmpty(codon.Properties["shortcut"])) { KeyGesture kg = MenuService.ParseShortcut(codon.Properties["shortcut"]); AddGestureToInputBindingOwner(inputBindingOwner, kg, Command, GetFeatureName()); InputGestureText = MenuService.GetDisplayStringForShortcut(kg); } }
void Child_Drop(object sender, System.Windows.DragEventArgs e) { var content = new System.Windows.Controls.ContentControl(); var bind = new System.Windows.Data.Binding(); var cdp = new ChannelDataProvider { ChannelName = (string)e.Data.GetData(typeof(string)), IsBindInDesign = true }; //cdp.ChannelName = node.Tag + "." + node.Text; bind.Source = cdp; System.Windows.Data.BindingOperations.SetBinding(content, System.Windows.Controls.ContentControl.ContentProperty, bind); //TODO:need to solve problem with drag mouse capturing // System.Windows.Point p=System.Windows.Input.Mouse.GetPosition(Schema.MainCanvas); System.Windows.Controls.Canvas.SetLeft(content, 0); System.Windows.Controls.Canvas.SetTop(content, 0); content.Width = 60; content.Height = 50; if (MainPanel.Resources[typeof(BaseChannel)] == null) { var dt = ((DataTemplate)XamlReader.Load(new XmlTextReader(new StringReader(StringResources.ChannelDefaultTemplate)))); dt.DataType = typeof(BaseChannel); var dk = new DataTemplateKey(typeof(BaseChannel)); MainPanel.Resources[dk] = dt; } UndoBuff.AddCommand(new AddGraphicsObject(content)); }
private static System.Windows.Data.Binding CopyBinding(System.Windows.Data.Binding oldBinding) { var result = new System.Windows.Data.Binding(); result.BindsDirectlyToSource = oldBinding.BindsDirectlyToSource; result.Converter = oldBinding.Converter; result.ConverterCulture = oldBinding.ConverterCulture; result.ConverterParameter = oldBinding.ConverterParameter; result.Mode = oldBinding.Mode; result.NotifyOnValidationError = oldBinding.NotifyOnValidationError; result.Path = oldBinding.Path; if (oldBinding.ElementName != null) { result.ElementName = oldBinding.ElementName; } else if (oldBinding.RelativeSource != null) { result.RelativeSource = oldBinding.RelativeSource; } else { result.Source = oldBinding.Source; } result.UpdateSourceTrigger = oldBinding.UpdateSourceTrigger; result.ValidatesOnExceptions = oldBinding.ValidatesOnExceptions; return(result); }
public static void LoadAndMonitor(INotifyPropertyChanged source, string sourceProperty, System.Windows.Controls.Control control, System.Windows.DependencyProperty controlProperty = null) { if (controlProperty == null) { if (control is System.Windows.Controls.TextBox) { controlProperty = System.Windows.Controls.TextBox.TextProperty; } if (control is System.Windows.Controls.CheckBox) { controlProperty = System.Windows.Controls.Primitives.ToggleButton.IsCheckedProperty; } if (control is System.Windows.Controls.ComboBox || control is System.Windows.Controls.ListBox) { controlProperty = System.Windows.Controls.Primitives.Selector.SelectedValueProperty; } if (control is Xceed.Wpf.Toolkit.IntegerUpDown) { controlProperty = Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty; } } var binding = new System.Windows.Data.Binding(sourceProperty); binding.Source = source; binding.IsAsync = true; control.SetBinding(controlProperty, binding); }
public override async void OnApplyTemplate() #endif { base.OnApplyTemplate(); InputBox = GetTemplateChild(InputBoxName) as TextBox; if (InputBox != null) { // manually adding // GetBindingExpression doesn't seem to respect TemplateBinding // so TextBoxBinding's code doesn't fire #if WINDOWS_STORE || WINDOWS_PHONE_APP var binding = new Windows.UI.Xaml.Data.Binding(); #elif WINDOWS_PHONE var binding = new System.Windows.Data.Binding(); #endif binding.Source = InputBox; binding.Path = new PropertyPath("Text"); SetBinding(ValueProperty, binding); TextBinding.SetUpdateSourceOnChange(InputBox, true); HookUpEventForIsSubmitOnEnterKey(); if (!ApplicationSpace.IsDesignMode) await DelayInputSelect(); } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); InputBox = GetTemplateChild(InputBoxName) as TextBox; if (InputBox != null) { // manually adding // GetBindingExpression doesn't seem to respect TemplateBinding // so TextBoxBinding's code doesn't fire var binding = new System.Windows.Data.Binding { Source = InputBox, Path = new PropertyPath("Text"), }; SetBinding(ValueProperty, binding); HookUpEventForIsSubmitOnEnterKey(); ThreadPool.QueueUserWorkItem(DelayInputSelect); } }
private void LoadGridDynamic() { var records = new ObservableCollection <Record>(); records.Add(new Record(new Property("FirstName", "Paul"), new Property("LastName", "Stovell"))); records.Add(new Record(new Property("FirstName", "Tony"), new Property("LastName", "Black"))); var columns = records.First() .Properties .Select((x, i) => new { Name = x.Name, Index = i }) .ToArray(); //foreach (var column in columns) //{ // var binding = new System.Windows.Data.Binding(string.Format("Properties[{0}].Value", column.Index)); // dataGrid.Columns.Add(new DataGridTextColumn() { Header = column.Name, Binding = binding }); //} foreach (var column in columns) { var binding = new System.Windows.Data.Binding(string.Format("Properties[{0}]", column.Index)); dataGrid.Columns.Add(new CustomBoundColumn() { Header = column.Name, Binding = binding, TemplateName = "CustomTemplate" }); } }
private static void SetSquareModeBinding(FrameworkElement element, SquareMode squareMode) { if (element == null) { throw new ArgumentNullException("element"); } //http://blog.wpfwonderland.com/2010/10/04/sizeable-yet-square-content-control/ System.Windows.Data.Binding Binding; switch (squareMode) { case SquareMode.WidthMatchesActualHeight: //Force the element's width to match its actual height. Binding = new System.Windows.Data.Binding(); Binding.Path = new PropertyPath(FrameworkElement.ActualHeightProperty.Name); Binding.RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self); element.SetBinding(FrameworkElement.WidthProperty, Binding); break; case SquareMode.HeightMatchesActualWidth: //Force the element's height to match its actual width. Binding = new System.Windows.Data.Binding(); Binding.Path = new PropertyPath(FrameworkElement.ActualWidthProperty.Name); Binding.RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self); element.SetBinding(FrameworkElement.HeightProperty, Binding); break; } }
public override void SubscribeToEvents() { var frameworkElement = Target as FrameworkElement; if (frameworkElement == null) { return; } #if WINDOWS_WPF var listenerBinding = new System.Windows.Data.Binding(_targetName) { Source = frameworkElement }; #endif #if WINDOWS_COMMON var listenerBinding = new Windows.UI.Xaml.Data.Binding() { Path = new PropertyPath(_targetName), Source = frameworkElement }; #endif var attachedProperty = DependencyProperty.RegisterAttached( "ListenAttached" + _targetName + Guid.NewGuid().ToString("N") , typeof(object) , typeof(FrameworkElement) , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue))); frameworkElement.SetBinding(attachedProperty, listenerBinding); }
public OrgChart() { InitializeComponent(); var model = new TreeModel <OrgMember, String>(); model.NodeKeyPath = "Key"; model.ParentNodePath = "Parent"; using (Stream stream = Demo.MainPage.Instance.GetStream("OrgChart", "xml")) { using (StreamReader reader = new StreamReader(stream)) { XElement root = XElement.Load(reader); XAttribute xa = root.Attribute("Date"); if (xa != null) { this.Date = xa.Value; } model.NodesSource = root.Descendants().OfType <XElement>().Select(x => new OrgMember(x)).ToList(); } } myDiagram.Model = model; // Data-bind Slider.Value to Diagram.Panel.Scale, once the Diagram.Panel // has been created by expanding the Diagram's ControlTemplate. // The Slider uses a logarithmic scale via the LogConverter defined below. myDiagram.TemplateApplied += (s, e) => { var b = new System.Windows.Data.Binding("Scale"); b.Source = myDiagram.Panel; b.Mode = System.Windows.Data.BindingMode.TwoWay; b.Converter = new LogConverter(); myLogScaleSlider.SetBinding(Slider.ValueProperty, b); }; myInfo.DataContext = this; }
private void SetEditorBinding(string path, DependencyProperty dependencyProperty) { System.Windows.Data.Binding binding = new System.Windows.Data.Binding(path); binding.Source = this; binding.Mode = System.Windows.Data.BindingMode.TwoWay; System.Windows.Data.BindingOperations.SetBinding(editor, dependencyProperty, binding); }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { TextBox editElement = new TextBox { BorderThickness = new Thickness(0.0), Padding = new Thickness(0.0) }; System.Windows.Data.Binding textBinding = new System.Windows.Data.Binding(cell.Column.Header + ".DisplayValue") { Source = dataItem }; editElement.SetBinding(TextBox.TextProperty, textBinding); System.Windows.Data.Binding backgroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Background") { Source = dataItem }; editElement.SetBinding(TextBlock.BackgroundProperty, backgroundBinding); System.Windows.Data.Binding foreGroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Foreground") { Source = dataItem }; editElement.SetBinding(TextBlock.ForegroundProperty, foreGroundBinding); return(editElement); }
/// <summary> /// 获取DataGridColumn BindingPath属性 /// </summary> /// <param name="datagridcolumn"></param> /// <returns>BindingPath属性</returns> private static string GetBindingPath(DataGridColumn datagridcolumn) { string r = string.Empty; try { System.Windows.Controls.DataGridBoundColumn column = (System.Windows.Controls.DataGridBoundColumn)datagridcolumn; System.Windows.Data.Binding matchBinding = (System.Windows.Data.Binding)column.Binding; r = matchBinding.Path.Path; } catch (Exception ex) { // TODO 如何获取 System.Windows.Controls.DataGridTemplateColumn 的 Binding 属性 if (ex.Message.Contains("System.Windows.Controls.DataGridTemplateColumn") && ex.Message.Contains("System.Windows.Controls.DataGridBoundColumn")) { r = datagridcolumn.SortMemberPath; // 暂时先取 SortMemberPath } else { throw ex; } } return(r); }
AutocompletePopup(FastColoredTextBox textBox, WindowsFormsHost host) { _timer = new Timer(); _timer.Tick += tick; InitializeComponent(); PlacementTarget = host; CustomPopupPlacementCallback = placePopup; _tb = textBox; _tb.KeyDown += new KeyEventHandler(keyDown); _tb.SelectionChanged += new EventHandler(selectionChanged); _tb.KeyPressed += new KeyPressEventHandler(keyPressed); _tb.LostFocus += tb_LostFocus; _visibleItems = new ObservableCollection <AutocompleteItem>(); AppearInterval = 500; SearchPattern = @"[\w\.]"; MinFragmentLength = 1; _timer.Start(); var binding = new System.Windows.Data.Binding(); binding.Source = _visibleItems; Liste.SetBinding(System.Windows.Controls.ListBox.ItemsSourceProperty, binding); }
private void PopulateAccentsStackPanel() { foreach (var accent in ThemeManager.Accents) { var rb = new RadioButton { Margin = new Thickness(2), Content = accent.Name, GroupName = "accents", FocusVisualStyle = null, Foreground = (Brush)accent.Resources["AccentBaseColorBrush"] }; rb.Checked += AccentRb_Checked; var binding = new Binding { Path = new PropertyPath("Config.Accent"), Converter = new StringToBooleanConverter(), ConverterParameter = (string)rb.Content }; rb.SetBinding(ToggleButton.IsCheckedProperty, binding); SpAccents.Children.Add(rb); } }
public override async void OnApplyTemplate() #endif { base.OnApplyTemplate(); InputBox = GetTemplateChild(InputBoxName) as TextBox; if (InputBox != null) { // manually adding // GetBindingExpression doesn't seem to respect TemplateBinding // so TextBoxBinding's code doesn't fire #if WINDOWS_STORE || WINDOWS_PHONE_APP var binding = new Windows.UI.Xaml.Data.Binding(); #elif WINDOWS_PHONE var binding = new System.Windows.Data.Binding(); #endif binding.Source = InputBox; binding.Path = new PropertyPath("Text"); SetBinding(ValueProperty, binding); TextBinding.SetUpdateSourceOnChange(InputBox, true); HookUpEventForIsSubmitOnEnterKey(); if (!ApplicationSpace.IsDesignMode) { await DelayInputSelect(); } } }
public MainWindow() { InitializeComponent(); TextBox X1 = new TextBox(); TextBox Y1 = new TextBox(); X1.Margin = new Thickness(0, 0, 20, 20); Y1.Margin = new Thickness(0, 0, 100, 100); X1.Width = 100; Y1.Width = 100; X1.Height = 200; Y1.Height = 200; X1.DataContext = myPoint; Y1.DataContext = myPoint; System.Windows.Data.Binding BindingX = new System.Windows.Data.Binding("X"); System.Windows.Data.Binding BindingY = new System.Windows.Data.Binding("Y"); BindingX.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; BindingY.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; BindingX.Mode = System.Windows.Data.BindingMode.TwoWay; BindingY.Mode = System.Windows.Data.BindingMode.TwoWay; BindingX.Source = myPoint; BindingY.Source = myPoint; X1.SetBinding(TextBox.TextProperty, BindingX); Y1.SetBinding(TextBox.TextProperty, BindingY); this.MainGrid.Children.Add(Y1); this.MainGrid.Children.Add(X1); X1.Text = "1"; }
/// <summary> /// Prepares the checkbox by creating bindings and hooking events. /// </summary> /// <param name="element">The container element.</param> /// <param name="item">The data item.</param> protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); MatchingTermItemContainer container = (MatchingTermItemContainer)element; if (this.ItemContainerStyle != null) { container.Style = this.ItemContainerStyle; } container.GotFocus += new RoutedEventHandler(this.Container_GotFocus); container.LostFocus += new RoutedEventHandler(this.Container_LostFocus); container.MouseEnter += new MouseEventHandler(this.Container_MouseEnter); container.MouseLeave += new MouseEventHandler(this.Container_MouseLeave); container.MouseEnterPopup += new MouseEventHandler(this.Container_MouseEnter); container.MouseLeavePopup += new MouseEventHandler(this.Container_MouseLeave); container.SelectionChanged += new EventHandler(this.Container_SelectionChanged); container.PopupOpening += new EventHandler(this.Container_PopupOpening); container.DataContext = item; container.SelectedItemMemberPath = this.SelectedItemMemberPath; container.AlternateItemsMemberPath = this.AlternateItemsMemberPath; container.SelectedItemTextMemberPath = this.SelectedItemTextMemberPath; container.FlyOutContentTemplate = this.FlyOutContentTemplate; container.EncodedItemTemplate = this.EncodedItemTemplate; container.IsSelectedMemberPath = this.IsSelectedMemberPath; System.Windows.Data.Binding lengthBinding = new System.Windows.Data.Binding(this.LengthMemberPath); lengthBinding.Mode = System.Windows.Data.BindingMode.TwoWay; container.SetBinding(MatchingTermItemContainer.SelectedItemTextLengthProperty, lengthBinding); this.containers.Add(container); this.containersByItem.Add(item, container); }
/// <summary> /// Creates a {Binding} expression without magic strings /// </summary> /// <remarks> /// http://handcraftsman.wordpress.com/2008/11/11/how-to-get-c-property-names-without-magic-strings/ /// http://msdn.microsoft.com/en-us/library/ms742863.aspx?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.WINDOWS.DATA.BINDING%29;k%28VS.XAMLEDITOR%29;k%28TargetFrameworkMoniker-%22.NETFRAMEWORK&k=VERSION=V4.0%22%29&rd=true /// </remarks> public static void Bind <TProperty>(this FrameworkElement target, DependencyProperty property, Expression <Func <TProperty> > expression) { Binding binding = new Binding(GetPropertyName(expression)); binding.Source = target.DataContext; target.SetBinding(property, binding); }
private void CheckPinOrUnPin() { Models.Manga item = this.DataContext as Models.Manga; System.Windows.Data.Binding b = new System.Windows.Data.Binding("IsPin"); b.Source = item; b.Mode = System.Windows.Data.BindingMode.TwoWay; this.SetBinding(TemplateNewRead.IsPinOrUnPinProperty, b); }
public void BindToProperty(object dataContext, System.Windows.Data.Binding binding) { if (null != dataContext) editText.DataContext = dataContext; editText.SetBinding(TextBox.TextProperty, binding); editText.SelectAll(); }
private void mainDiagram_TemplateApplied(object sender, DiagramEventArgs e) { var bind = new System.Windows.Data.Binding("Scale"); bind.Source = mainDiagram.Panel; bind.Mode = System.Windows.Data.BindingMode.TwoWay; zoomSlider.SetBinding(Slider.ValueProperty, bind); }
private IList <IMvxUpdateableBinding> GetOrCreateBindingsList(FrameworkElement attachedObject) { var existing = attachedObject.GetValue(BindingsListProperty) as IList <IMvxUpdateableBinding>; if (existing != null) { return(existing); } // attach the list var newList = new List <IMvxUpdateableBinding>(); attachedObject.SetValue(BindingsListProperty, newList); // create a binding watcher for the list #if WINDOWS_WPF var binding = new System.Windows.Data.Binding(); #endif #if WINDOWS_COMMON var binding = new Windows.UI.Xaml.Data.Binding(); #endif bool attached = false; Action attachAction = () => { if (attached) { return; } BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding); attached = true; }; Action detachAction = () => { if (!attached) { return; } #if WINDOWS_COMMON attachedObject.ClearValue(DataContextWatcherProperty); #else BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty); #endif attached = false; }; attachAction(); attachedObject.Loaded += (o, args) => { attachAction(); }; attachedObject.Unloaded += (o, args) => { detachAction(); }; return(newList); }
public TBReadOnlyEdit() : base() { this.Width = 0; this.Height = 0; var bd = new System.Windows.Data.Binding("IsReadOnlyEdit"); this.SetBinding(TextBoxErp.IsReadOnlyProperty, bd); }
public static void SetForeground(this FrameworkElement element, System.Windows.Data.Binding binding) { if (element == null) { throw new ArgumentNullException("element"); } element.SetBinding(GetForegroundProperty(element), binding); }
private void listBoxClasses_SelectionChanged(object sender, SelectionChangedEventArgs e) { string label = ((Pair)listBoxClasses.SelectedItem).ClassLabel; ObservableCollection <string> localImages = ImagesInClass[label]; System.Windows.Data.Binding b = new System.Windows.Data.Binding(); b.Source = localImages; listBoxImages.SetBinding(ItemsControl.ItemsSourceProperty, b); }
private void initializeThemeColors() { if (View.Instance != null && ThemeColors == null) { System.Windows.Data.Binding binding = new System.Windows.Data.Binding(); binding.Source = View.Instance.ThemeColors; SetBinding(ThemeColorsProperty, binding); } }
private void CheckPinOrUnPin() { // Kiểm tra Title được pin chưa Models.Manga item = this.DataContext as Models.Manga; System.Windows.Data.Binding b = new System.Windows.Data.Binding("IsPin"); b.Source = item; b.Mode = System.Windows.Data.BindingMode.TwoWay; this.SetBinding(IsPinOrUnPinProperty, b); }
void UpdateGrid() { if (_grid == null) { return; } _grid.ColumnDefinitions.Clear(); _grid.RowDefinitions.Clear(); if (_converter == null) { _converter = new LayoutOptionsToLengthConverter(); } if (_orientation == Orientation.Vertical) { for (int i = 0; i < ItemsControl.Items.Count; i++) { var element = _grid.Children.OfType <UIElement>().Skip(i).First(); WPFGrid.SetRow(element, i); WPFGrid.SetColumn(element, 0); var row = new WPFRowDefinition { Height = new WPFGridLength(0, WPFGridUnitType.Auto) }; _grid.RowDefinitions.Add(row); var binding = new System.Windows.Data.Binding(View.VerticalOptionsProperty.PropertyName) { Source = ItemsSource.Skip(i).FirstOrDefault(), Converter = _converter }; row.SetBinding(WPFRowDefinition.HeightProperty, binding); } } else { for (int i = 0; i < ItemsControl.Items.Count; i++) { var element = _grid.Children.OfType <UIElement>().Skip(i).First(); WPFGrid.SetRow(element, 0); WPFGrid.SetColumn(element, i); var col = new WPFColumnDefinition { Width = new WPFGridLength(0, WPFGridUnitType.Auto) }; _grid.ColumnDefinitions.Add(col); var binding = new System.Windows.Data.Binding(View.HorizontalOptionsProperty.PropertyName) { Source = ItemsSource.Skip(i).FirstOrDefault(), Converter = _converter }; col.SetBinding(WPFColumnDefinition.WidthProperty, binding); } } }
/// <summary> /// Uses tags on the child controls to bind to properties on the source entity object /// </summary> /// <param name="uc"></param> /// <param name="sourceEntity">The entity to bind to</param> public static void BindControls(this FrameworkElement uc, object sourceEntity) { uc.Tag = sourceEntity; IEnumerable elements = LogicalTreeHelper.GetChildren(uc); foreach (object child in elements) { FrameworkElement currentUserControl = child as FrameworkElement; if (currentUserControl != null) { object tagValue = currentUserControl.Tag; if (tagValue != null && tagValue.ToString() != String.Empty) { System.Windows.Data.Binding binding = new System.Windows.Data.Binding(tagValue.ToString()); binding.Source = sourceEntity; if (currentUserControl as CheckBox != null) { currentUserControl.SetBinding(CheckBox.IsCheckedProperty, binding); } else if (currentUserControl as ComboBox != null) { if (((ComboBox)currentUserControl).IsEditable == true) { currentUserControl.SetBinding(ComboBox.TextProperty, binding); } else { currentUserControl.SetBinding(ComboBox.SelectedItemProperty, binding); } } else if (currentUserControl as ListBox != null) { currentUserControl.SetBinding(ListBox.SelectedItemProperty, binding); } else if (currentUserControl as TextBox != null) { currentUserControl.SetBinding(TextBox.TextProperty, binding); } else if (currentUserControl as BindablePasswordBox != null) { currentUserControl.SetBinding(BindablePasswordBox.PasswordProperty, binding); } else if (currentUserControl as RadioButton != null) { currentUserControl.SetBinding(RadioButton.IsCheckedProperty, binding); } } else { } BindControls(currentUserControl, sourceEntity); } } }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); if (Owner != null) { System.Windows.Data.Binding binding = new System.Windows.Data.Binding("Background"); binding.Source = Owner; this.SetBinding(Window.BackgroundProperty, binding); } }
public SecureServicesLayerConfig() { DefaultStyleKey = typeof(SecureServicesLayerConfig); SecureServicesLayerConfigViewModel viewModel = new SecureServicesLayerConfigViewModel(); this.DataContext = viewModel; System.Windows.Data.Binding binding = new System.Windows.Data.Binding(); binding.Source = viewModel; binding.Path = new PropertyPath("IsEnabled"); binding.Mode = System.Windows.Data.BindingMode.TwoWay; SetBinding(IsEnabledProperty, binding); }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { var numericEditor = new DoubleUpDown(); numericEditor.Minimum = Minimum; numericEditor.Maximum = Maximum; numericEditor.Increment = Increment; numericEditor.FormatString = FormatString; var sourceBinding = this.Binding as System.Windows.Data.Binding; var binding = new System.Windows.Data.Binding(); binding.Path = sourceBinding.Path; binding.Converter = new TargetTypeConverter(); numericEditor.SetBinding(DoubleUpDown.ValueProperty, binding); return numericEditor; }
private IList<IMvxUpdateableBinding> GetOrCreateBindingsList(FrameworkElement attachedObject) { var existing = attachedObject.GetValue(BindingsListProperty) as IList<IMvxUpdateableBinding>; if (existing != null) return existing; // attach the list var newList = new List<IMvxUpdateableBinding>(); attachedObject.SetValue(BindingsListProperty, newList); // create a binding watcher for the list #if WINDOWS_WPF var binding = new System.Windows.Data.Binding(); #endif #if WINDOWS_COMMON var binding = new Windows.UI.Xaml.Data.Binding(); #endif bool attached = false; Action attachAction = () => { if (attached) return; BindingOperations.SetBinding(attachedObject, DataContextWatcherProperty, binding); attached = true; }; Action detachAction = () => { if (!attached) return; #if WINDOWS_COMMON attachedObject.ClearValue(DataContextWatcherProperty); #else BindingOperations.ClearBinding(attachedObject, DataContextWatcherProperty); #endif attached = false; }; attachAction(); attachedObject.Loaded += (o, args) => { attachAction(); }; attachedObject.Unloaded += (o, args) => { detachAction(); }; return newList; }
public BindingExpression(BindingExpressionKey key, BindingBase binding, PropertyEntry<object> propertyEntry) { this.propertyEntry = propertyEntry; Binding = binding; this.Key = key; if(IsTwoWayBinding && string.IsNullOrEmpty(((Binding)this.Binding).Path)) Guard.InvalidOperation(SR.TwoWayBindingRequiresPathExceptionMessage); WpfBindingMode mode = IsTwoWayBinding ? WpfBindingMode.TwoWay : WpfBindingMode.OneWay; WpfBinding wpfBinding = new WpfBinding("PropertyValue." + ((Binding)binding).Path) { Source = propertyEntry, Mode = mode}; if(Property == null) Guard.ArgumentException("propertyName"); MethodInfo createMethod = typeof(PropertyChangeListener<>).MakeGenericType(key.property.PropertyType).GetMethod("Create", BindingFlags.Static | BindingFlags.Public); listener = (IPropertyChangeListener)createMethod.Invoke(null, new object[] { wpfBinding, new Action<object>(UpdateTargetProperty), Property.GetValue(Control) }); if(IsTwoWayBinding) Property.AddValueChanged(Control, OnTargerPropertyChanged); }
protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) { TextBlock cellElement = new TextBlock(); System.Windows.Data.Binding textBinding = new System.Windows.Data.Binding(cell.Column.Header + ".DisplayValue") {Source = dataItem}; cellElement.SetBinding(TextBlock.TextProperty, textBinding); System.Windows.Data.Binding backgroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Background") {Source = dataItem}; cellElement.SetBinding(TextBlock.BackgroundProperty, backgroundBinding); System.Windows.Data.Binding foreGroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Foreground") {Source = dataItem}; cellElement.SetBinding(TextBlock.ForegroundProperty, foreGroundBinding); return cellElement; }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { TextBox editElement = new TextBox {BorderThickness = new Thickness(0.0), Padding = new Thickness(0.0)}; System.Windows.Data.Binding textBinding = new System.Windows.Data.Binding(cell.Column.Header + ".DisplayValue") {Source = dataItem}; editElement.SetBinding(TextBox.TextProperty, textBinding); System.Windows.Data.Binding backgroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Background") {Source = dataItem}; editElement.SetBinding(TextBlock.BackgroundProperty, backgroundBinding); System.Windows.Data.Binding foreGroundBinding = new System.Windows.Data.Binding(cell.Column.Header + ".Foreground") {Source = dataItem}; editElement.SetBinding(TextBlock.ForegroundProperty, foreGroundBinding); return editElement; }
/// <summary> /// Initializes a new instance of a <see cref="MapNavigator"/>. /// </summary> public MapNavigator() { InitializeComponent(); Opacity = 0.5; // bind Foreground and FontSize properties to child controls // (after the control has loaded!) Loaded += (s, e) => { var bForeground = new System.Windows.Data.Binding("Foreground") { Source = this }; var bFontSize = new System.Windows.Data.Binding("FontSize") { Source = this }; foreach (HyperlinkButton btn in LayoutRoot.Children) { btn.SetBinding(HyperlinkButton.ForegroundProperty, bForeground); btn.SetBinding(HyperlinkButton.FontSizeProperty, bFontSize); } }; }
private SearchPane() { InitializeComponent(); searchModeComboBox.Items.Add(new { Image = Images.Class, Name = "Type" }); searchModeComboBox.Items.Add(new { Image = Images.Property, Name = "Member" }); searchModeComboBox.Items.Add(new { Image = Images.Literal, Name = "Constant" }); searchModeComboBox.SelectedIndex = SearchMode_Type; var bindingMatchEnum = new System.Windows.Data.Binding("MatchEnum"); bindingMatchEnum.Source = MainWindow.Instance.SessionSettings.FilterSettings; checkBoxSearchEnumerationOnly.SetBinding(CheckBox.IsCheckedProperty, bindingMatchEnum); var bindingSearchInCurrentAssembly = new System.Windows.Data.Binding("SearchInCurrentAssembly"); bindingSearchInCurrentAssembly.Source = MainWindow.Instance.SessionSettings.FilterSettings; checkBoxSearchSelectedAssemblyOnly.SetBinding(CheckBox.IsCheckedProperty, bindingSearchInCurrentAssembly); MainWindow.Instance.CurrentAssemblyListChanged += MainWindow_Instance_CurrentAssemblyListChanged; MainWindow.Instance.SessionSettings.FilterSettings.PropertyChanged += FilterSettings_PropertyChanged; }
void AddDatePicker(DataTable table) { for (int i = 0; i < table.Columns.Count; ++i) { if (table.Columns[i].DataType.IsEquivalentTo(typeof(DateTime))) { DataGridTemplateColumn dgct = new DataGridTemplateColumn(); System.Windows.FrameworkElementFactory factory = new System.Windows.FrameworkElementFactory(typeof(DatePicker)); System.Windows.Data.Binding b = new System.Windows.Data.Binding(table.Columns[i].ColumnName); b.UpdateSourceTrigger = System.Windows.Data.UpdateSourceTrigger.PropertyChanged; factory.SetValue(DatePicker.SelectedDateProperty, b); System.Windows.DataTemplate cellEditingTemplate = new System.Windows.DataTemplate(); cellEditingTemplate.VisualTree = factory; dgct.CellTemplate = cellEditingTemplate; dgct.Header = table.Columns[i].ColumnName; DGrid.Columns[i] = dgct; } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); SampleSelector = GetTemplateChild(SampleSelectorName) as Grid; SelectedHueColor = GetTemplateChild(SelectedHueColorName) as Rectangle; var body = GetTemplateChild(BodyName) as Grid; if (body != null) { _monitor = new MovementMonitor(); _monitor.Movement += _monitor_Movement; _monitor.MonitorControl(body); } ColorSlider = GetTemplateChild(ColorSliderName) as ColorSlider; if (ColorSlider != null) { if (Thumb == null) Thumb = new ColorSliderThumb(); ColorSlider.ColorChanged += ColorSlider_ColorChanged; if(SelectedHueColor != null) { var binding = new System.Windows.Data.Binding { Source = ColorSlider, Path = new PropertyPath("SolidColorBrush"), }; SelectedHueColor.SetBinding(Shape.FillProperty, binding); } } }
public override void SubscribeToEvents() { var frameworkElement = Target as FrameworkElement; if (frameworkElement == null) return; #if WINDOWS_PHONE || WINDOWS_WPF var listenerBinding = new System.Windows.Data.Binding(_targetName) { Source = frameworkElement }; #endif #if NETFX_CORE var listenerBinding = new Windows.UI.Xaml.Data.Binding() { Path = new PropertyPath(_targetName), Source = frameworkElement }; #endif var attachedProperty = DependencyProperty.RegisterAttached( "ListenAttached" + _targetName + Guid.NewGuid().ToString("N") , typeof(object) , typeof(FrameworkElement) , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue))); frameworkElement.SetBinding(attachedProperty, listenerBinding); }
private void initializeColorBrush() { if (View.Instance != null && ColorBrush == null && !string.IsNullOrEmpty(ColorBrushName)) { System.Windows.Data.Binding binding = new System.Windows.Data.Binding(); binding.Source = View.Instance.ApplicationColorSet; binding.Path = new PropertyPath(ColorBrushName); binding.Mode = System.Windows.Data.BindingMode.TwoWay; binding.Converter = new ColorToSolidColorBrushConverter(); SetBinding(ColorBrushProperty, binding); } }
public SmoothStreamingVideoAdapter() { GoToLiveCommand = new Command(new Action(GoToLive)); SourceBinding = new System.Windows.Data.Binding("CurrentItem.SourceUri") { Source = this }; SourceBindingProperty = SmoothStreamingMediaElement.SmoothStreamingSourceProperty; }
private void RenderPrivileges(SecurityObject secObject, RadTabItem tabItem) { int rowHeight = 20; int rowIndex = 0; tabItem.Style = (Style)Application.Current.Resources["InnerTabItem"]; ScrollViewer sv = new ScrollViewer(); sv.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; //sv.Margin = new Thickness(3); sv.Background = (SolidColorBrush)Application.Current.Resources["PanelDarkBackground"]; sv.BorderBrush = (SolidColorBrush)Application.Current.Resources["PanelDarkBackground"]; Grid grid = new Grid(); grid.Background = (SolidColorBrush)Application.Current.Resources["PanelDarkBackground"]; sv.Content = grid; tabItem.Content = sv; foreach (var privilege in mPrivileges) { grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(rowHeight) }); CheckBox checkBox = new CheckBox(); grid.Children.Add(checkBox); checkBox.Content = privilege.Name; Grid.SetRow(checkBox, rowIndex); Grid.SetColumn(checkBox, 0); rowIndex++; RolePrivilegeViewModel rolePrivilegeViewModel; //Check set privileges var rolePrivilege = mRole.RolePrivileges.FirstOrDefault(x => x.SecObjectId == secObject.Id && x.PrivilegeId == privilege.Id); if (rolePrivilege != null) { rolePrivilegeViewModel = new RolePrivilegeViewModel(rolePrivilege); rolePrivilegeViewModel.HasAccess = true; } else { rolePrivilege = new RolePrivilege(); rolePrivilege.RoleId = mRoleId; rolePrivilege.SecObjectId = secObject.Id; rolePrivilege.PrivilegeId = privilege.Id; rolePrivilegeViewModel = new RolePrivilegeViewModel(rolePrivilege); rolePrivilegeViewModel.HasAccess = false; } mRolePrivilegesViewModel.Add(rolePrivilegeViewModel); //Bind System.Windows.Data.Binding checkBoxBinding = new System.Windows.Data.Binding("HasAccess"); checkBoxBinding.Mode = System.Windows.Data.BindingMode.TwoWay; checkBoxBinding.Source = rolePrivilegeViewModel; checkBox.SetBinding(CheckBox.IsCheckedProperty, checkBoxBinding); } }
public MediaElementVideoAdapter() { SourceBinding = new System.Windows.Data.Binding("CurrentItem.SourceUri") { Source = this }; }
/// <summary> /// 创建计划历史 /// </summary> public RadGridView CreatePlanHistorityGridView() { RadGridView rgView = new RadGridView(); rgView.ShowGroupPanel = true; rgView.AutoGenerateColumns = false; rgView.IsReadOnly = true; rgView.Name = "planHistotry"; rgView.RowIndicatorVisibility = Visibility.Collapsed; rgView.IsFilteringAllowed = true; GridViewDataColumn gvColumn0 = new GridViewDataColumn(); gvColumn0.Header = "申报单位"; gvColumn0.DataMemberBinding = new System.Windows.Data.Binding("Plan.Airlines.ShortName"); //Telerik.Windows.Data.CountFunction cf = new Telerik.Windows.Data.CountFunction(); //cf.Caption = "总计(项):"; //gvColumn0.AggregateFunctions.Add(cf); GridViewDataColumn gvColumn1 = new GridViewDataColumn(); gvColumn1.Header = "执行年份"; gvColumn1.DataMemberBinding = new System.Windows.Data.Binding("Annual.Year"); GridViewDataColumn gvColumn2 = new GridViewDataColumn(); gvColumn2.Header = "执行月份"; gvColumn2.DataMemberBinding = new System.Windows.Data.Binding("PerformMonth"); GridViewDataColumn gvColumn3 = new GridViewDataColumn(); gvColumn3.Header = "活动类别"; gvColumn3.DataMemberBinding = new System.Windows.Data.Binding("ActionCategoryOperation"); GridViewDataColumn gvColumn4 = new GridViewDataColumn(); gvColumn4.Header = "引进/退出方式"; System.Windows.Data.Binding bingding4 = new System.Windows.Data.Binding("TargetCategory.ActionName"); gvColumn4.DataMemberBinding = bingding4; GridViewDataColumn gvColumn5 = new GridViewDataColumn(); gvColumn5.Header = "机型"; gvColumn5.DataMemberBinding = new System.Windows.Data.Binding("AircraftType.Name"); GridViewDataColumn gvColumn6 = new GridViewDataColumn(); gvColumn6.Header = "净增座位(座)"; gvColumn6.DataMemberBinding = new System.Windows.Data.Binding("SeatingCapacity"); GridViewDataColumn gvColumn7 = new GridViewDataColumn(); gvColumn7.Header = "净增商载(吨)"; gvColumn7.DataMemberBinding = new System.Windows.Data.Binding("CarryingCapacity"); GridViewDataColumn gvColumn8 = new GridViewDataColumn(); gvColumn8.Header = "备注"; gvColumn8.DataMemberBinding = new System.Windows.Data.Binding("Note"); GridViewDataColumn gvColumn9 = new GridViewDataColumn(); gvColumn9.Header = "申请状态"; gvColumn9.DataMemberBinding = new System.Windows.Data.Binding("IsApply"); //默认分组 GroupDescriptor countryDescriptor = new GroupDescriptor(); countryDescriptor.Member = "IsApply"; countryDescriptor.DisplayContent = "申请状态"; rgView.GroupDescriptors.Add(countryDescriptor); rgView.AutoExpandGroups = true; SerialColumn gvColumn10 = new SerialColumn(); ResourceDictionary dictionary = new ResourceDictionary(); dictionary.Source = new Uri("/CAAC.Infrastructure;component/Resources/CafmStyle.xaml", UriKind.Relative); gvColumn10.Header = "序号"; gvColumn10.CellStyle = (Style)dictionary["style"]; rgView.Columns.Add(gvColumn10); rgView.Columns.Add(gvColumn0); rgView.Columns.Add(gvColumn1); rgView.Columns.Add(gvColumn2); rgView.Columns.Add(gvColumn3); rgView.Columns.Add(gvColumn4); rgView.Columns.Add(gvColumn5); rgView.Columns.Add(gvColumn6); rgView.Columns.Add(gvColumn7); rgView.Columns.Add(gvColumn8); rgView.Columns.Add(gvColumn9); return rgView; }
private void CreateUserContextMenu() { UserContextMenu = new ContextMenu(); var whisper = new MenuItem(); whisper.Header = "Whisper"; whisper.Click += WhisperOnClick; UserContextMenu.Items.Add(whisper); var addFriend = new MenuItem(); addFriend.Header = "Add Friend"; addFriend.Click += AddFriendOnClick; UserContextMenu.Items.Add(addFriend); var ban = new MenuItem(); ban.Header = "Ban"; ban.Click += BanOnClick; UserContextMenu.Items.Add(ban); var profile = new MenuItem(); profile.Header = "Profile"; profile.Click += ProfileOnClick; UserContextMenu.Items.Add(profile); var binding = new System.Windows.Data.Binding(); binding.Mode = System.Windows.Data.BindingMode.OneWay; binding.Converter = new BooleanToVisibilityConverter(); binding.Source = BanMenuVisible; ban.SetBinding(VisibilityProperty, binding); }
private static System.Windows.Data.Binding CopyBinding(System.Windows.Data.Binding oldBinding) { var result = new System.Windows.Data.Binding(); result.BindsDirectlyToSource = oldBinding.BindsDirectlyToSource; result.Converter = oldBinding.Converter; result.ConverterCulture = oldBinding.ConverterCulture; result.ConverterParameter = oldBinding.ConverterParameter; result.Mode = oldBinding.Mode; result.NotifyOnValidationError = oldBinding.NotifyOnValidationError; result.Path = oldBinding.Path; if (oldBinding.ElementName != null) result.ElementName = oldBinding.ElementName; else if (oldBinding.RelativeSource != null) result.RelativeSource = oldBinding.RelativeSource; else result.Source = oldBinding.Source; result.UpdateSourceTrigger = oldBinding.UpdateSourceTrigger; result.ValidatesOnExceptions = oldBinding.ValidatesOnExceptions; return result; }
/// <summary> /// 初始化RadWindow控件的Content的值 /// </summary> /// <returns></returns> public RadGridView CreateGridView() { RadGridView gridview = new RadGridView(); gridview.ShowGroupPanel = false; gridview.AutoGenerateColumns = false; gridview.CanUserFreezeColumns = false; gridview.CanUserResizeRows = false; gridview.IsReadOnly = true; gridview.IsFilteringAllowed = false; gridview.RowIndicatorVisibility = Visibility.Collapsed; GridViewDataColumn gv1 = new GridViewDataColumn(); gv1.Header = "运营开始"; System.Windows.Data.Binding bing1 = new System.Windows.Data.Binding("StartDate"); bing1.StringFormat = "yyyy/M/d"; gv1.DataMemberBinding = bing1; GridViewDataColumn gv2 = new GridViewDataColumn(); gv2.Header = "运营结束"; System.Windows.Data.Binding bing2 = new System.Windows.Data.Binding("StartDate"); bing2.StringFormat = "yyyy/M/d"; gv2.DataMemberBinding = bing2; GridViewDataColumn gv3 = new GridViewDataColumn(); gv3.Header = "航空公司"; gv3.DataMemberBinding = new System.Windows.Data.Binding("Airlines.ShortName"); GridViewDataColumn gv4 = new GridViewDataColumn(); gv4.Header = "飞机号"; gv4.DataMemberBinding = new System.Windows.Data.Binding("Aircraft.RegNumber"); GridViewDataColumn gv5 = new GridViewDataColumn(); gv5.Header = "机型"; gv5.DataMemberBinding = new System.Windows.Data.Binding("Aircraft.AircraftType.Name"); GridViewDataColumn gv6 = new GridViewDataColumn(); gv6.Header = "引进方式"; gv6.DataMemberBinding = new System.Windows.Data.Binding("ImportCategory.ActionName"); GridViewDataColumn gv7 = new GridViewDataColumn(); gv7.Header = "退出方式"; gv7.DataMemberBinding = new System.Windows.Data.Binding("ExportCategory.ActionName"); GridViewDataColumn gv8 = new GridViewDataColumn(); gv8.Header = "备注"; gv8.DataMemberBinding = new System.Windows.Data.Binding("Note"); gridview.Columns.Add(gv1); gridview.Columns.Add(gv2); gridview.Columns.Add(gv3); gridview.Columns.Add(gv4); gridview.Columns.Add(gv5); gridview.Columns.Add(gv6); gridview.Columns.Add(gv7); gridview.Columns.Add(gv8); return gridview; }
/// <summary> ///创建运营飞机 /// </summary> /// <returns></returns> public RadGridView CreatOperationGridView() { RadGridView rgView = new RadGridView(); rgView.ShowGroupPanel = true; rgView.AutoGenerateColumns = false; rgView.IsReadOnly = true; rgView.Name = "aircraftDetail"; rgView.RowIndicatorVisibility = Visibility.Collapsed; rgView.IsFilteringAllowed = true; GridViewDataColumn gvColumn1 = new GridViewDataColumn(); gvColumn1.Header = "航空公司"; gvColumn1.DataMemberBinding = new System.Windows.Data.Binding("Airlines.ShortName"); GridViewDataColumn gvColumn2 = new GridViewDataColumn(); gvColumn2.Header = "注册号"; gvColumn2.DataMemberBinding = new System.Windows.Data.Binding("RegNumber"); GridViewDataColumn gvColumn3 = new GridViewDataColumn(); gvColumn3.Header = "机型"; gvColumn3.DataMemberBinding = new System.Windows.Data.Binding("AircraftType.Name"); GridViewDataColumn gvColumn4 = new GridViewDataColumn(); gvColumn4.Header = "引进方式"; System.Windows.Data.Binding bingding4 = new System.Windows.Data.Binding("ImportCategory.ActionName"); gvColumn4.DataMemberBinding = bingding4; GridViewDataColumn gvColumn5 = new GridViewDataColumn(); gvColumn5.Header = "引进日期"; gvColumn5.DataMemberBinding = new System.Windows.Data.Binding("ImportDate"); gvColumn5.DataFormatString = "yyyy/M/d"; GridViewDataColumn gvColumn6 = new GridViewDataColumn(); gvColumn6.Header = "出厂日期"; gvColumn6.DataMemberBinding = new System.Windows.Data.Binding("FactoryDate"); gvColumn6.DataFormatString = "yyyy/M/d"; SerialColumn gvColumn7 = new SerialColumn(); ResourceDictionary dictionary = new ResourceDictionary(); dictionary.Source = new Uri("/CAAC.Infrastructure;component/Resources/CafmStyle.xaml", UriKind.Relative); gvColumn7.Header = "序号"; gvColumn7.CellStyle = (Style)dictionary["style"]; rgView.Columns.Add(gvColumn7); rgView.Columns.Add(gvColumn1); rgView.Columns.Add(gvColumn2); rgView.Columns.Add(gvColumn3); rgView.Columns.Add(gvColumn4); rgView.Columns.Add(gvColumn5); rgView.Columns.Add(gvColumn6); return rgView; }
public static void SetPage(this System.Windows.Window window, Xamarin.Forms.Page page) { window.Content = RendererFactory.Create(page); var titleBinding = new System.Windows.Data.Binding(Page.TitleProperty.PropertyName) { Source = page }; window.SetBinding(System.Windows.Window.TitleProperty, titleBinding); }
public override void SetupCustomUIElements(Controls.dynNodeView NodeUI) { //add a text box to the input grid of the control tb = new TextBox(); tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; tb.VerticalAlignment = System.Windows.VerticalAlignment.Center; NodeUI.inputGrid.Children.Add(tb); System.Windows.Controls.Grid.SetColumn(tb, 0); System.Windows.Controls.Grid.SetRow(tb, 0); //turn off the border SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)); tb.Background = backgroundBrush; tb.BorderThickness = new Thickness(0); tb.DataContext = this; var bindingSymbol = new System.Windows.Data.Binding("Symbol") { Mode = BindingMode.TwoWay }; tb.SetBinding(TextBox.TextProperty, bindingSymbol); tb.TextChanged += new TextChangedEventHandler(tb_TextChanged); }