or
<common:RecentDocuments x:Key="RecentDocuments" /><common:RecentPlaces x:Key="RecentPlaces" /><common:AvailableTemplates x:Key="AvailableTemplates" /><common:HelpItems x:Key="HelpItemsTemplate" /><StackPanel Margin="15 15 0 0"> <TextBlock Text="Recent Documents" FontSize="14" FontWeight="Bold" Margin="0 0 0 2" /> <Rectangle Height="1" Fill="{StaticResource DottedLineBrush}" /> <ItemsControl ItemsSource="{StaticResource RecentDocuments}" Margin="0 4 0 0" ItemTemplate="{StaticResource RecentDocumentTemplate}" /></StackPanel>foreach (var c in radGridViewTest.Columns)
{
var factory = new FrameworkElementFactory(typeof(Button), "myButton");
factory.SetValue(CursorProperty, Cursors.Hand); // OK
factory.SetBinding(ContentProperty, new Binding(string.Format("[{0}]", 4))); //OK
c.CellTemplate= new DataTemplate();
var mh = new RoutedEventHandler(onClick);
factory.AddHandler(Button.ClickEvent, mh,true); // won't work ...
c.CellTemplate.VisualTree = factory;
c.CellTemplate.Seal();
}
col = new GridViewDataColumn { Header = vspriorities[key], CellTemplate = new DataTemplate() }; cbx = new FrameworkElementFactory(typeof(CheckBox)); ; cbx.SetValue(IsHitTestVisibleProperty, true); cbx.SetValue(FocusableProperty, true); cbx.SetValue(TagProperty, null); cbx.SetValue(MarginProperty, new Thickness(0, 0, 0, 0)); cbx.SetValue(TagProperty, key); cbx.SetBinding(DataContextProperty, new Binding()); cbx.SetBinding(CheckBox.IsCheckedProperty, new Binding("PrioritaetId") { ConverterParameter = key, Converter = (IValueConverter)TryFindResource("EqualsConverter"), Mode = BindingMode.OneTime }); //cbx.AddHandler(GridViewCheckBox.ClickEvent, new RoutedEventHandler(VSPriority_Checked)); cbx.AddHandler(CheckBox.ClickEvent, new RoutedEventHandler (VSPriority_Checked)); //templBorder = new FrameworkElementFactory(typeof(Border)); //templBorder.SetValue(StyleProperty, TryFindResource("GridBorder")); //templBorder.AppendChild(cbx); col.CellTemplate.VisualTree = cbx; col.CellTemplate.Seal(); StatusColumns.Add(col); lvData.Columns.Insert(idx++, col);