本文整理汇总了C#中System.Windows.FrameworkElementFactory类的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElementFactory类的具体用法?C# FrameworkElementFactory怎么用?C# FrameworkElementFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FrameworkElementFactory类属于System.Windows命名空间,在下文中一共展示了FrameworkElementFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:7,代码来源:WpfListItemHelper.cs
示例3: CreateByViewType
public DataTemplate CreateByViewType(Type viewModelType, Type viewType)
{
var dt = new DataTemplate(viewModelType);
var factory = new FrameworkElementFactory(viewType);
dt.VisualTree = factory;
return dt;
}
开发者ID:UnstableMutex,项目名称:MVVMTemplateSelection,代码行数:7,代码来源:DataTemplateFactory.cs
示例4: ColorWheel
public ColorWheel()
{
// Define the ItemsPanel template.
FrameworkElementFactory factoryRadialPanel =
new FrameworkElementFactory(typeof(RadialPanel));
ItemsPanel = new ItemsPanelTemplate(factoryRadialPanel);
// Create the DataTemplate for the items.
DataTemplate template = new DataTemplate(typeof(Brush));
ItemTemplate = template;
// Create a FrameworkElementFactory based on Rectangle.
FrameworkElementFactory elRectangle =
new FrameworkElementFactory(typeof(Rectangle));
elRectangle.SetValue(Rectangle.WidthProperty, 4.0);
elRectangle.SetValue(Rectangle.HeightProperty, 12.0);
elRectangle.SetValue(Rectangle.MarginProperty,
new Thickness(1, 8, 1, 8));
elRectangle.SetBinding(Rectangle.FillProperty, new Binding(""));
// Use that factory for the visual tree.
template.VisualTree = elRectangle;
// Set the items in the ListBox.
PropertyInfo[] props = typeof(Brushes).GetProperties();
foreach (PropertyInfo prop in props)
Items.Add((Brush)prop.GetValue(null, null));
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:29,代码来源:ColorWheel.cs
示例5: ColorGridBox
public ColorGridBox()
{
// Define the ItemsPanel template.
FrameworkElementFactory factoryUnigrid =
new FrameworkElementFactory(typeof(UniformGrid));
factoryUnigrid.SetValue(UniformGrid.ColumnsProperty, 8);
ItemsPanel = new ItemsPanelTemplate(factoryUnigrid);
// Add items to the ListBox.
foreach (string strColor in strColors)
{
// Create Rectangle and add to ListBox.
Rectangle rect = new Rectangle();
rect.Width = 12;
rect.Height = 12;
rect.Margin = new Thickness(4);
rect.Fill = (Brush)
typeof(Brushes).GetProperty(strColor).GetValue(null, null);
Items.Add(rect);
// Create ToolTip for Rectangle.
ToolTip tip = new ToolTip();
tip.Content = strColor;
rect.ToolTip = tip;
}
// Indicate that SelectedValue is Fill property of Rectangle item.
SelectedValuePath = "Fill";
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:28,代码来源:ColorGridBox.cs
示例6: TextBlock
public static sw.FrameworkElementFactory TextBlock()
{
var factory = new sw.FrameworkElementFactory(typeof(swc.TextBlock));
factory.SetBinding(swc.TextBlock.TextProperty, new sw.Data.Binding { Path = TextPath });
factory.SetValue(swc.TextBlock.MarginProperty, new sw.Thickness(2));
return factory;
}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:7,代码来源:WpfListItemHelper.cs
示例7: ComboBoxBackend
//private static readonly DataTemplate DefaultTemplate;
static ComboBoxBackend()
{
if (System.Windows.Application.Current.Resources.MergedDictionaries.Count == 0 ||
!System.Windows.Application.Current.Resources.MergedDictionaries.Any(x => x.Contains(typeof(ExComboBox))))
{
var factory = new FrameworkElementFactory(typeof(WindowsSeparator));
factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
var sepTemplate = new ControlTemplate(typeof(ComboBoxItem));
sepTemplate.VisualTree = factory;
DataTrigger trigger = new DataTrigger();
trigger.Binding = new Binding(".[1]") { Converter = new TypeToStringConverter() };
trigger.Value = typeof(ItemSeparator).Name;
trigger.Setters.Add(new Setter(Control.TemplateProperty, sepTemplate));
trigger.Setters.Add(new Setter(UIElement.IsEnabledProperty, false));
ContainerStyle = new Style(typeof(ComboBoxItem));
ContainerStyle.Triggers.Add(trigger);
}
else
{
ContainerStyle = null;
}
}
开发者ID:steffenWi,项目名称:xwt,代码行数:26,代码来源:ComboBoxBackend.cs
示例8: GenerateMetaColumns
private void GenerateMetaColumns()
{
while (_gridView.Columns.Count > 1)
{
_gridView.Columns.RemoveAt(1);
}
// dynamically generate columns for meta data
var container = theView.DataContext as ContainerVM;
if (container != null)
{
foreach (var info in container.KnownMetaData)
{
GridViewColumn col = new GridViewColumn
{
Header = info.Name,
HeaderContainerStyle = TryFindResource(string.Format("{0}AlignColHeader", info.HeaderAlignment)) as Style,
Width = info.Width,
};
var txt = new FrameworkElementFactory(typeof(TextBlock));
txt.SetBinding(TextBlock.TextProperty, new Binding(string.Format("MetaData[{0}].Value", info.Name)) { Converter = info.Formatter, ConverterParameter = info.FormatParameter });
txt.SetValue(TextBlock.TextTrimmingProperty, TextTrimming.CharacterEllipsis);
txt.SetValue(TextBlock.TextAlignmentProperty, info.ContentAlignment);
col.CellTemplate = new DataTemplate() { VisualTree = txt };
_gridView.Columns.Add(col);
}
}
}
开发者ID:soukoku,项目名称:MExplorer,代码行数:30,代码来源:ProviderView.xaml.cs
示例9: CreateBoundColumnTemplate
internal static FrameworkElementFactory CreateBoundColumnTemplate (ApplicationContext ctx, Widget parent, CellViewCollection views, string dataPath = ".")
{
if (views.Count == 1)
return CreateBoundCellRenderer(ctx, parent, views[0], dataPath);
FrameworkElementFactory container = new FrameworkElementFactory (typeof (StackPanel));
container.SetValue (StackPanel.OrientationProperty, System.Windows.Controls.Orientation.Horizontal);
foreach (CellView view in views) {
var factory = CreateBoundCellRenderer(ctx, parent, view, dataPath);
factory.SetValue(FrameworkElement.MarginProperty, CellMargins);
if (view.VisibleField != null)
{
var binding = new Binding(dataPath + "[" + view.VisibleField.Index + "]");
binding.Converter = new BooleanToVisibilityConverter();
factory.SetBinding(UIElement.VisibilityProperty, binding);
}
else if (!view.Visible)
factory.SetValue(UIElement.VisibilityProperty, Visibility.Collapsed);
container.AppendChild(factory);
}
return container;
}
开发者ID:m13253,项目名称:xwt,代码行数:27,代码来源:CellUtil.cs
示例10: 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;
}
开发者ID:LexaGal,项目名称:Plants,代码行数:32,代码来源:FrameworkElementFactoriesBuilder.cs
示例11: CreateDefaultTemplate
internal static DataTemplate CreateDefaultTemplate()
{
var dataTemplate = new DataTemplate();
var factory = new FrameworkElementFactory(typeof(ContentPresenter));
dataTemplate.VisualTree = factory;
return dataTemplate;
}
开发者ID:gitter-badger,项目名称:Gu.Wpf.DataGrid2D,代码行数:7,代码来源:Helpers.cs
示例12: KernelOnComponentRegistered
private void KernelOnComponentRegistered(string key, IHandler handler)
{
Type implementation = handler.ComponentModel.Implementation;
if (implementation.Namespace == null ||
!implementation.Namespace.EndsWith("ViewModels"))
{
return;
}
var viewTypeName = implementation.Namespace.Replace("ViewModels", "Views") + "." +
implementation.Name.Replace("ViewModel", "View");
var qualifiedViewTypeName = implementation.AssemblyQualifiedName.Replace(implementation.FullName, viewTypeName);
Type viewType = Type.GetType(qualifiedViewTypeName, false);
if (viewType == null)
{
throw new InvalidOperationException();
}
var dt = new DataTemplate {DataType = viewType};
var viewFactory = new FrameworkElementFactory(viewType);
dt.VisualTree = viewFactory;
_resources.Add(new DataTemplateKey(implementation), dt);
}
开发者ID:ArildF,项目名称:Core,代码行数:27,代码来源:ViewModelRegistrationFacility.cs
示例13: TextureManager
public TextureManager()
{
InitializeComponent();
DataGridTemplateColumn col = new DataGridTemplateColumn();
Binding imgBinding = new Binding("Name") { Converter = new Controls.PathToImageConverter() };
FrameworkElementFactory imgFactory = new FrameworkElementFactory(typeof(Image));
imgFactory.SetBinding(Image.SourceProperty, imgBinding);
imgFactory.SetValue(Image.MaxHeightProperty, 64.0);
imgFactory.SetValue(Image.MaxWidthProperty, 64.0);
imgFactory.SetValue(Image.TagProperty, "PreviewImage");
((DataGridTemplateColumn)col).CellTemplate = new DataTemplate();
((DataGridTemplateColumn)col).CellTemplate.VisualTree = imgFactory;
col.Header = "Preview";
gridView.Columns.Add(col);
formStack.Children.Add(textureForm_ = new ReflectiveForm(typeof(Urho.Texture)));
texTree.DataContext = Project.inst().Textures;
texTree.SelectedItemChanged += texTree_SelectedItemChanged;
gridView.DataContext = flat_ = Project.inst().Textures.GetFlat();
formStack.Children.Add(nothing_ = new NothingHere("Texture"));
nothing_.Visibility = System.Windows.Visibility.Visible;
textureForm_.Visibility = System.Windows.Visibility.Collapsed;
}
开发者ID:nonconforme,项目名称:UrContent,代码行数:25,代码来源:TextureManager.xaml.cs
示例14: 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 };
}
开发者ID:Moeinmontazeripour,项目名称:xamarin-forms-wpf,代码行数:26,代码来源:ItemTemplateConverter.cs
示例15: ListColorsEvenElegantlier
public ListColorsEvenElegantlier()
{
Title = "List Colors Even Elegantlier";
DataTemplate template = new DataTemplate(typeof(NamedBrush));
FrameworkElementFactory factoryStack = new FrameworkElementFactory(typeof(StackPanel));
factoryStack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
template.VisualTree = factoryStack;
FrameworkElementFactory factoryRectangle = new FrameworkElementFactory(typeof(Rectangle));
factoryRectangle.SetValue(Rectangle.WidthProperty, 16.0);
factoryRectangle.SetValue(Rectangle.HeightProperty, 16.0);
factoryRectangle.SetValue(Rectangle.MarginProperty, new Thickness(2));
factoryRectangle.SetValue(Rectangle.StrokeProperty, SystemColors.WindowTextBrush);
factoryRectangle.SetBinding(Rectangle.FillProperty, new Binding("Brush"));
factoryStack.AppendChild(factoryRectangle);
FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBlock));
factoryTextBlock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);
factoryTextBlock.SetValue(TextBlock.TextProperty, new Binding("Name"));
factoryStack.AppendChild(factoryTextBlock);
ListBox lstbox = new ListBox();
lstbox.Width = 150;
lstbox.Height = 150;
Content = lstbox;
lstbox.ItemTemplate = template;
lstbox.ItemsSource = NamedBrush.All;
lstbox.SelectedValuePath = "Brush";
lstbox.SetBinding(ListBox.SelectedValueProperty, "Background");
lstbox.DataContext = this;
}
开发者ID:JianchengZh,项目名称:kasicass,代码行数:34,代码来源:ListColorsEvenElegantlier.cs
示例16: CreateCellTemplate
internal static System.Windows.DataTemplate CreateCellTemplate(EntityFieldInfo entityFieldInfo,DataGrid dataGrid)
{
DataTemplate dataTemplate = new DataTemplate();
FrameworkElementFactory contentControl = new FrameworkElementFactory(typeof(ContentControl));
contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
Style contentControlStyle = new Style();
contentControl.SetValue(ContentControl.StyleProperty, contentControlStyle);
DataTemplate tpl = new DataTemplate();
if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Color)
{
FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
Binding binding = CreateBindingOneWay(entityFieldInfo.Path);
binding.Converter = new StringToBrushConverter();
grid.SetBinding(Grid.BackgroundProperty, binding);
tpl.VisualTree = grid;
contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
dataTemplate.VisualTree = contentControl;
}
else
{
FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBlock));
if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Pr)
{ textBox.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); }
textBox.SetBinding(TextBlock.TextProperty, CreateBindingOneWay(entityFieldInfo.Path));
tpl.VisualTree = textBox;
contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
dataTemplate.VisualTree = contentControl;
}
return dataTemplate;
}
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:32,代码来源:DataGridTemplateBuilder.cs
示例17: 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,
}
});
}
}
开发者ID:22v2,项目名称:KanColleViewer,代码行数:28,代码来源:LogListView.cs
示例18: EditableTextBlock
public EditableTextBlock()
{
var textBox = new FrameworkElementFactory(typeof(TextBox));
textBox.SetValue(Control.PaddingProperty, new Thickness(1)); // 1px for border
textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
textBox.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
var editTemplate = new DataTemplate { VisualTree = textBox };
var textBlock = new FrameworkElementFactory(typeof(TextBlock));
textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
textBlock.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(TextBlock_MouseDown));
textBlock.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("Text") { Source = this });
var viewTemplate = new DataTemplate { VisualTree = textBlock };
var style = new System.Windows.Style(typeof(EditableTextBlock));
var trigger = new Trigger { Property = IsInEditModeProperty, Value = true };
trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = editTemplate });
style.Triggers.Add(trigger);
trigger = new Trigger { Property = IsInEditModeProperty, Value = false };
trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = viewTemplate });
style.Triggers.Add(trigger);
Style = style;
}
开发者ID:alexandrebaker,项目名称:Eto,代码行数:26,代码来源:EditableTextBlock.cs
示例19: 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
示例20: CreateFallbackViewTemplate
internal static DataTemplate CreateFallbackViewTemplate(string errorText) {
var factory = new FrameworkElementFactory(typeof(FallbackView));
factory.SetValue(FallbackView.TextProperty, errorText);
var res = new DataTemplate() { VisualTree = factory };
res.Seal();
return res;
}
开发者ID:sk8tz,项目名称:DevExpress.Mvvm.Free,代码行数:7,代码来源:IViewLocator.cs
注:本文中的System.Windows.FrameworkElementFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论