Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
140773 | Nov 6,2018 10:18 PM UTC | Nov 8,2018 06:17 AM UTC | WPF | 1 |
![]() |
Tags: SfDataGrid |
public class SfDataGridBehavior: Behavior<SfDataGrid>
{
protected override void OnAttached()
{
TemplateViewDefinition templateViewDefinition = new TemplateViewDefinition();
templateViewDefinition.RowTemplate = GetDataTemplate();
this.AssociatedObject.DetailsViewDefinition.Add(templateViewDefinition);
}
private DataTemplate GetDataTemplate()
{
FrameworkElementFactory comboBoxAdv = new FrameworkElementFactory(typeof(ComboBoxAdv));
comboBoxAdv.SetValue(ComboBoxAdv.HorizontalAlignmentProperty, HorizontalAlignment.Center);
comboBoxAdv.SetValue(ComboBoxAdv.VerticalAlignmentProperty, VerticalAlignment.Center);
comboBoxAdv.SetValue(ComboBoxAdv.SelectedValueProperty, "ProductName");
comboBoxAdv.SetValue(ComboBoxAdv.DisplayMemberPathProperty, "ProductName");
comboBoxAdv.SetValue(ComboBoxAdv.WidthProperty, 200d);
Binding binding = new Binding();
binding.Path = new PropertyPath("DataContext.OrderList");
binding.ElementName = this.AssociatedObject.Name;
comboBoxAdv.SetBinding(ComboBoxAdv.ItemsSourceProperty, binding);
var dataTemplate = new DataTemplate() { VisualTree = comboBoxAdv };
return dataTemplate;
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.