Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static DataGridTextColumn GetTextColumn(string ColumnName, string FormatString, bool AlignRight)
- {
- DataGridTextColumn c = new DataGridTextColumn();
- c.Header = Test.Common.UIBizObjectCache.LocalizedText.GetLocalizedText(ColumnName);
- c.Binding = new System.Windows.Data.Binding(ColumnName);
- if (!string.IsNullOrWhiteSpace(FormatString))
- c.Binding.StringFormat = FormatString;
- if (AlignRight)
- {
- Style cellRightAlignedStyle = new Style(typeof(DataGridCell));
- cellRightAlignedStyle.Setters.Add(new Setter(DataGridCell.HorizontalAlignmentProperty, HorizontalAlignment.Right));
- c.CellStyle = cellRightAlignedStyle;
- }
- //var buttonTemplate = new FrameworkElementFactory(typeof(Button));
- //buttonTemplate.Text = "X";
- //buttonTemplate.AddHandler(
- // Button.ClickEvent,
- // new RoutedEventHandler((o, e) => HandleColumnHeaderButtonClick(o, e))
- // );
- //c.HeaderTemplate=new DataTemplate(){VisualTree = buttonTemplate};
- return c;
- }
- string colProperty = "Name";
- DataGridTextColumn col = new DataGridTextColumn();
- col.Binding = new Binding(colProperty);
- var spHeader = new StackPanel() { Orientation = Orientation.Horizontal };
- spHeader.Children.Add(new TextBlock(new Run(colProperty)));
- var button = new Button();
- button.Click += Button_Filter_Click;
- button.Content = "Filter";
- spHeader.Children.Add(button);
- col.Header = spHeader;
- dataGrid.Columns.Add(col);
Add Comment
Please, Sign In to add comment