本文整理汇总了C#中System.Windows.FrameworkElementFactory.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElementFactory.SetBinding方法的具体用法?C# FrameworkElementFactory.SetBinding怎么用?C# FrameworkElementFactory.SetBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElementFactory
的用法示例。
在下文中一共展示了FrameworkElementFactory.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateItemTemplate
private DataTemplate CreateItemTemplate()
{
var template = new DataTemplate();
template.VisualTree = new FrameworkElementFactory(typeof(StackPanel));
var txtBlock = new FrameworkElementFactory(typeof(TextBlock));
txtBlock.SetBinding(TextBlock.TextProperty, new Binding("Street1"));
template.VisualTree.AppendChild(txtBlock);
txtBlock = new FrameworkElementFactory(typeof(TextBlock));
txtBlock.SetBinding(TextBlock.TextProperty, new Binding("City"));
template.VisualTree.AppendChild(txtBlock);
var trigger = new MultiDataTrigger();
trigger.Conditions.Add(
new Condition(
new Binding("Cty"), //misspelling
"Tallahassee"
)
);
trigger.Conditions.Add(
new Condition(
new Binding("StateOrProvince"),
"Florida"
)
);
template.Triggers.Add(trigger);
return template;
}
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:34,代码来源:UIBoundToCustomerWithContentControlAndMultiTriggers.cs
示例2: EditableBlock
public static sw.FrameworkElementFactory EditableBlock(swd.RelativeSource relativeSource)
{
var factory = new sw.FrameworkElementFactory(typeof(EditableTextBlock));
var binding = new sw.Data.Binding { Path = TextPath, RelativeSource = relativeSource, Mode = swd.BindingMode.TwoWay, UpdateSourceTrigger = swd.UpdateSourceTrigger.PropertyChanged };
factory.SetBinding(EditableTextBlock.TextProperty, binding);
return factory;
}
示例3: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var template = value as Xamarin.Forms.DataTemplate;
var uc = new FrameworkElementFactory(typeof(UserControl));
if (template != null)
{
uc.SetBinding(UserControl.ContentProperty, new MultiBinding
{
Converter = new CellToViewConverter(),
Bindings =
{
new Binding(),
new Binding { Source = template }
}
});
}
else
{
uc.SetBinding(UserControl.ContentProperty, new Binding
{
Converter = new ModelToViewConverter()
});
}
return new DataTemplate { VisualTree = uc };
}
示例4: CreateTemplate
private static DataTemplate CreateTemplate()
{
DataTemplate template = new DataTemplate {DataType = typeof(UiDataProviderNode)};
FrameworkElementFactory stackPanel = new FrameworkElementFactory(typeof(StackPanel));
stackPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
FrameworkElementFactory image = new FrameworkElementFactory(typeof(Image));
image.SetValue(HeightProperty, 16d);
image.SetValue(Image.SourceProperty, new Binding("Icon"));
image.SetValue(MarginProperty, new Thickness(3));
stackPanel.AppendChild(image);
//FrameworkElementFactory icon = new FrameworkElementFactory(typeof(ContentPresenter));
//icon.SetValue(HeightProperty, 16d);
//icon.SetValue(ContentPresenter.ContentProperty, new Binding("Icon"));
//icon.SetValue(MarginProperty, new Thickness(3));
//stackPanel.AppendChild(icon);
FrameworkElementFactory textBlock = new FrameworkElementFactory(typeof(TextBlock));
textBlock.SetBinding(TextBlock.TextProperty, new Binding("Title"));
textBlock.SetBinding(ToolTipProperty, new Binding("Description"));
textBlock.SetValue(MarginProperty, new Thickness(3));
stackPanel.AppendChild(textBlock);
template.VisualTree = stackPanel;
return template;
}
示例5: TextBlock
public static sw.FrameworkElementFactory TextBlock ()
{
var factory = new sw.FrameworkElementFactory (typeof (swc.TextBlock));
factory.SetBinding (swc.TextBlock.TextProperty, new sw.Data.Binding { Path = new sw.PropertyPath("Text"), Mode = swd.BindingMode.TwoWay });
factory.SetBinding(swc.TextBlock.ForegroundProperty, new sw.Data.Binding { Path = new sw.PropertyPath("TextColor"), Mode = swd.BindingMode.OneWay, Converter = new ColorConverter() });
return factory;
}
示例6: TreeGridViewColumn
public TreeGridViewColumn()
: base()
{
ResourceDictionary resourceDictionary = new ResourceDictionary();
resourceDictionary.Source = new Uri("pack://application:,,,/Yuhan.WPF.TreeListView;component/Resources/TreeListView.xaml");
//this.CellTemplate = resourceDictionary["CellTemplate"] as DataTemplate;
DataTemplate template = new DataTemplate();
FrameworkElementFactory factory = new FrameworkElementFactory(typeof(DockPanel));
Expander = new FrameworkElementFactory(typeof(ToggleButton));
Expander.Name = "Expander";
Expander.SetValue(ToggleButton.StyleProperty, resourceDictionary["ExpandCollapseToggleStyle"] as Style);
Expander.SetBinding(ToggleButton.VisibilityProperty, new Binding()
{
Source = this.Expandable,
Converter = new BooleanToVisibilityConverter()
});
Expander.SetBinding(ToggleButton.MarginProperty, new Binding("Level")
{
Converter = new LevelToIndentConverter(),
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(TreeListViewItem), 1)
});
Expander.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsExpanded")
{
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(TreeListViewItem), 1)
});
Expander.SetValue(ToggleButton.ClickModeProperty, ClickMode.Press);
ContentControlFactory = new FrameworkElementFactory(typeof(ContentControl));
ContentControlFactory.SetBinding(ContentControl.ContentProperty, new Binding(FieldName));
factory.AppendChild(Expander);
factory.AppendChild(ContentControlFactory);
template.VisualTree = factory;
template.Triggers.Add(new DataTrigger()
{
Binding = new Binding("HasItems")
{
RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(TreeListViewItem), 1),
},
Value = false,
Setters = { new Setter(ToggleButton.VisibilityProperty, Visibility.Hidden, "Expander") }
});
this.CellTemplate = template;
}
示例7: UcTableView_SizeChanged
void UcTableView_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (dt == null)
{
return;
}
_gridview.Columns.Clear();
foreach (DataColumn c in dt.Columns)
{
GridViewColumn gvc = new GridViewColumn();
gvc.Header = c.ColumnName;
if (BShowDetails)
{
gvc.Width = (_listview.ActualWidth - 65) / dt.Columns.Count;
}
else
{
gvc.Width = (_listview.ActualWidth - 25) / dt.Columns.Count;
}
gvc.SetValue(HorizontalAlignmentProperty, HorizontalAlignment.Center);
//gvc.DisplayMemberBinding = (new Binding(c.ColumnName));
FrameworkElementFactory text = new FrameworkElementFactory(typeof(TextBlock));
text.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
text.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);
text.SetBinding(TextBlock.TextProperty, new Binding(c.ColumnName));
DataTemplate dataTemplate = new DataTemplate() { VisualTree = text };
gvc.CellTemplate = dataTemplate;
_gridview.Columns.Add(gvc);
}
if (BShowDetails)
{
GridViewColumn gvc_details = new GridViewColumn();
gvc_details.Header = "详情";
FrameworkElementFactory button_details = new FrameworkElementFactory(typeof(Button));
button_details.SetResourceReference(Button.HorizontalContentAlignmentProperty, HorizontalAlignment.Center);
button_details.SetValue(Button.WidthProperty, 40.0);
button_details.AddHandler(Button.ClickEvent, new RoutedEventHandler(details_Click));
button_details.SetBinding(Button.TagProperty, new Binding(dt.Columns[1].ColumnName));
button_details.SetValue(Button.ContentProperty, ">>");
button_details.SetValue(Button.ForegroundProperty, Brushes.Blue);
button_details.SetValue(Button.FontSizeProperty, 14.0);
button_details.SetBinding(Button.VisibilityProperty, new Binding(dt.Columns[0].ColumnName) { Converter = new VisibleBtnConverter() });
DataTemplate dataTemplate_details = new DataTemplate() { VisualTree = button_details };
gvc_details.CellTemplate = dataTemplate_details;
_gridview.Columns.Add(gvc_details);
}
_listview.ItemsSource = null;
_listview.ItemsSource = dt.DefaultView;
}
示例8: GroupByControl
static GroupByControl()
{
// This DefaultStyleKey will only be used in design-time.
DefaultStyleKeyProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new Markup.ThemeKey( typeof( Views.TableView ), typeof( GroupByControl ) ) ) );
FrameworkElementFactory staircaseFactory = new FrameworkElementFactory( typeof( StaircasePanel ) );
ItemsPanelTemplate itemsPanelTemplate = new ItemsPanelTemplate( staircaseFactory );
RelativeSource ancestorSource = new RelativeSource( RelativeSourceMode.FindAncestor, typeof( GroupByControl ), 1 );
Binding binding = new Binding();
binding.Path = new PropertyPath( GroupByControl.ConnectionLineAlignmentProperty );
binding.Mode = BindingMode.OneWay;
binding.RelativeSource = ancestorSource;
staircaseFactory.SetBinding( StaircasePanel.ConnectionLineAlignmentProperty, binding );
binding = new Binding();
binding.Path = new PropertyPath( GroupByControl.ConnectionLineOffsetProperty );
binding.Mode = BindingMode.OneWay;
binding.RelativeSource = ancestorSource;
staircaseFactory.SetBinding( StaircasePanel.ConnectionLineOffsetProperty, binding );
binding = new Binding();
binding.Path = new PropertyPath( GroupByControl.ConnectionLinePenProperty );
binding.Mode = BindingMode.OneWay;
binding.RelativeSource = ancestorSource;
staircaseFactory.SetBinding( StaircasePanel.ConnectionLinePenProperty, binding );
binding = new Binding();
binding.Path = new PropertyPath( GroupByControl.StairHeightProperty );
binding.Mode = BindingMode.OneWay;
binding.RelativeSource = ancestorSource;
staircaseFactory.SetBinding( StaircasePanel.StairHeightProperty, binding );
binding = new Binding();
binding.Path = new PropertyPath( GroupByControl.StairSpacingProperty );
binding.Mode = BindingMode.OneWay;
binding.RelativeSource = ancestorSource;
staircaseFactory.SetBinding( StaircasePanel.StairSpacingProperty, binding );
itemsPanelTemplate.Seal();
ItemsControl.ItemsPanelProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( itemsPanelTemplate ) );
DataGridControl.ParentDataGridControlPropertyKey.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new PropertyChangedCallback( GroupByControl.ParentGridControlChangedCallback ) ) );
DataGridControl.DataGridContextPropertyKey.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( new PropertyChangedCallback( GroupByControl.DataGridContextChangedCallback ) ) );
FocusableProperty.OverrideMetadata( typeof( GroupByControl ), new FrameworkPropertyMetadata( false ) );
}
示例9: DocUIDataGrid
static DocUIDataGrid()
{
ColDict = new Dictionary<string, GetColumn>();
ColDict.Add("string", (Binding b) =>
{
DataGridTextColumn col = new DataGridTextColumn();
col.Binding = b;
col.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
return col;
});
ColDict.Add("combobox", (Binding b) =>
{
DataTemplate dt = new DataTemplate();
FrameworkElementFactory templatecheckbox = new FrameworkElementFactory(typeof(ComboBox));
templatecheckbox.SetBinding(ComboBox.TextProperty, b);
dt.VisualTree = templatecheckbox;
DataGridTemplateColumn col = new DataGridTemplateColumn();
col.CanUserResize = false;
col.CellTemplate = dt;
return col;
});
}
示例10: ChangeIsDeleted
void ChangeIsDeleted()
{
if (_deletationType == LogicalDeletationType.All)
{
if (!IsColumnShown)
{
var gridViewColumn = new GridViewColumn();
gridViewColumn.Header = "Дата удаления";
gridViewColumn.Width = 150;
var dataTemplate = new DataTemplate();
var txtElement = new FrameworkElementFactory(typeof(IsDeletedTextBlock));
dataTemplate.VisualTree = txtElement;
var binding = new Binding();
var bindingPath = string.Format("RemovalDate");
binding.Path = new PropertyPath(bindingPath);
binding.Mode = BindingMode.OneWay;
txtElement.SetBinding(IsDeletedTextBlock.TextProperty, binding);
gridViewColumn.CellTemplate = dataTemplate;
ListViewLayoutManager.SetCanUserResize(gridViewColumn, false);
gridView.Columns.Add(gridViewColumn);
}
}
else if (IsColumnShown)
{
gridView.Columns.Remove(IsDeletedColumn);
}
}
示例11: ShowResourcesGained_DataContextChanged
private void ShowResourcesGained_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
RollDiceAction rollDice = e.NewValue as RollDiceAction;
Dictionary<GamePlayer, ResourceList> result = rollDice.PlayersResources;
basePanel.Children.Clear();
foreach (KeyValuePair<GamePlayer, ResourceList> kvp in result)
{
// add list of resources
ItemsControl resources = new ItemsControl();
FrameworkElementFactory stackPanelElement = new FrameworkElementFactory(typeof(StackPanel));
stackPanelElement.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
resources.ItemsPanel = new ItemsPanelTemplate() { VisualTree = stackPanelElement};
resources.Height = 90;
Binding binding = new Binding()
{
Converter = new ResourceConverter()
};
FrameworkElementFactory imageElement = new FrameworkElementFactory(typeof(Image));
imageElement.SetBinding(Image.SourceProperty, binding);
imageElement.SetValue(Image.HeightProperty, 80.0);
imageElement.SetValue(Image.WidthProperty, 80.0);
resources.ItemTemplate = new DataTemplate()
{
VisualTree = imageElement
};
basePanel.Children.Add(resources);
resources.ItemsSource = kvp.Value;
}
}
示例12: CreateBoundCellRenderer
internal static FrameworkElementFactory CreateBoundCellRenderer(CellView view, string dataPath = ".")
{
TextCellView textView = view as TextCellView;
if (textView != null) {
FrameworkElementFactory factory = new FrameworkElementFactory (typeof (SWC.TextBlock));
factory.SetValue (FrameworkElement.MarginProperty, CellMargins);
if (textView.TextField != null)
factory.SetBinding (SWC.TextBlock.TextProperty, new Binding (dataPath + "[" + textView.TextField.Index + "]"));
return factory;
}
ImageCellView imageView = view as ImageCellView;
if (imageView != null) {
FrameworkElementFactory factory = new FrameworkElementFactory (typeof (ImageBox));
factory.SetValue (FrameworkElement.MarginProperty, CellMargins);
if (imageView.ImageField != null) {
var binding = new Binding (dataPath + "[" + imageView.ImageField.Index + "]")
{ Converter = new ImageToImageSourceConverter () };
factory.SetBinding (ImageBox.ImageSourceProperty, binding);
}
return factory;
}
throw new NotImplementedException ();
}
示例13: SelectTemplate
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
var rule = item as RuleViewModel;
if (rule == null)
return null;
FrameworkElementFactory checkBoxFactory = new FrameworkElementFactory(typeof(CheckBox));
Binding isCheckedBinding = new Binding("IsSelected")
{
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
};
checkBoxFactory.SetBinding(CheckBox.IsCheckedProperty, isCheckedBinding);
FrameworkElementFactory textBlockFactory = new FrameworkElementFactory(typeof(TextBlock));
textBlockFactory.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);
textBlockFactory.SetValue(TextBlock.TextProperty, (rule.Index + 1).ToString());
textBlockFactory.SetValue(TextBlock.MarginProperty, new Thickness(0, 5, 0, 0));
FrameworkElementFactory stackPanelFactory = new FrameworkElementFactory(typeof(StackPanel));
stackPanelFactory.AppendChild(checkBoxFactory);
stackPanelFactory.AppendChild(textBlockFactory);
return new DataTemplate { VisualTree = stackPanelFactory };
}
开发者ID:pedone,项目名称:DecisionTableAnalizer,代码行数:25,代码来源:ContradictionSelectionHeaderTemplateSelector.cs
示例14: OnLogSourceChanged
private static void OnLogSourceChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
ListView listView = d as ListView;
LogItemCollection collection = e.NewValue as LogItemCollection;
listView.ItemsSource = collection;
GridView gridView = listView.View as GridView;
int count = 0;
gridView.Columns.Clear();
foreach (var col in collection.Columns)
{
var cell = new FrameworkElementFactory(typeof(TextBlock));
cell.SetBinding(TextBlock.TextProperty, new Binding(string.Format("[{0}]", count++)));
cell.SetValue(FrameworkElement.MarginProperty, new Thickness(0, 4, 0, 4));
gridView.Columns.Add(
new GridViewColumn
{
Header = new TextBlock { Text = col, FontSize = 11, Margin = new Thickness(5, 4, 5, 4) },
CellTemplate = new DataTemplate
{
DataType = typeof(LogItemCollection),
VisualTree = cell,
}
});
}
}
示例15: CreateOnOffServiceScheduleButtonTemplate
public FrameworkElementFactory CreateOnOffServiceScheduleButtonTemplate()
{
FrameworkElementFactory buttonTemplate = new FrameworkElementFactory(typeof (CheckBox));
buttonTemplate.SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsOn")
{
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
});
buttonTemplate.AddHandler(
ToggleButton.CheckedEvent,
new RoutedEventHandler((o, e) =>
{
DataGridServiceScheduleView dataGridServiceScheduleView =
((FrameworkElement) o).DataContext as DataGridServiceScheduleView;
if (dataGridServiceScheduleView != null)
{
dataGridServiceScheduleView.IsOn = true.ToString();
}
}));
buttonTemplate.AddHandler(
ToggleButton.UncheckedEvent,
new RoutedEventHandler((o, e) =>
{
DataGridServiceScheduleView dataGridServiceScheduleView =
((FrameworkElement) o).DataContext as DataGridServiceScheduleView;
if (dataGridServiceScheduleView != null)
{
dataGridServiceScheduleView.IsOn = false.ToString();
}
}));
return buttonTemplate;
}