本文整理汇总了C#中System.Windows.Data.Binding类的典型用法代码示例。如果您正苦于以下问题:C# Binding类的具体用法?C# Binding怎么用?C# Binding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binding类属于System.Windows.Data命名空间,在下文中一共展示了Binding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HumanMacroDialog
public HumanMacroDialog(Word.Range text, int jobNumber)
{
this.text = text;
this.jobNumber = jobNumber;
InitializeComponent();
Binding binding = new Binding();
binding.Source = text;
binding.Path = new PropertyPath("Text");
textToWorkWith.SetBinding(TextBox.TextProperty, binding);
numItems.Content = numSections + " paragraph" + (numSections == 1 ? "" : "s") + " selected, each as a separate task";
item1 = new ComboBoxItem();
item1.Content = "Paragraph";
item2 = new ComboBoxItem();
item2.Content = "Sentence";
separatorBox.Items.Add(item1);
separatorBox.Items.Add(item2);
separatorBox.SelectedValue = item1;
returnAsComments = new ComboBoxItem();
returnAsComments.Content = "Comments";
returnAsInline = new ComboBoxItem();
returnAsInline.Content = "In-Line Changes";
returnTypeBox.Items.Add(returnAsComments);
returnTypeBox.Items.Add(returnAsInline);
returnTypeBox.SelectedValue = returnAsComments;
}
开发者ID:tummykung,项目名称:soylent,代码行数:30,代码来源:HumanMacroDialog.xaml.cs
示例2: MainPage_Loaded
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
try
{
var progressIndicator = SystemTray.ProgressIndicator;
if (progressIndicator != null)
{
return;
}
progressIndicator = new ProgressIndicator();
SystemTray.SetProgressIndicator(this, progressIndicator);
Binding binding = new Binding("IsLoading") { Source = _viewModel };
BindingOperations.SetBinding(
progressIndicator, ProgressIndicator.IsVisibleProperty, binding);
binding = new Binding("IsLoading") { Source = _viewModel };
BindingOperations.SetBinding(
progressIndicator, ProgressIndicator.IsIndeterminateProperty, binding);
progressIndicator.Text = "Loading games...";
_viewModel.LoadPage(lastPagePulled, PAGE_COUNT);
lastPagePulled += 1;
}
catch (Exception exception)
{
ErrorHandler.Save(exception, MobileTypeEnum.WP8);
}
}
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:31,代码来源:Games.xaml.cs
示例3: Comment
public Comment(Node hostNode)
{
HostNode = hostNode;
var scrollViewer = new ScrollViewer
{
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
Height = 70,
CanContentScroll = true
};
var textBlock = new TextBlock
{
Background = Brushes.Transparent,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(5),
FontSize = 12
};
Child = scrollViewer;
CornerRadius = new CornerRadius(5);
scrollViewer.Content = textBlock;
var bindingTextToTextBlock = new Binding("Text")
{
Source = this,
Mode = BindingMode.OneWay
};
textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);
hostNode.SpaceCanvas.Children.Add(this);
}
开发者ID:bsudhakarGit,项目名称:TUM.CMS.VPLControl,代码行数:34,代码来源:Comment.cs
示例4: ToString
public override string ToString()
{
g = (SayUnixTime)base.Tag;
Binding myBinding = new Binding("unixtime");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Source = g;
txttime.SetBinding(TextBox.TextProperty, myBinding);
Binding myBinding2 = new Binding("timezone");
myBinding2.Mode = BindingMode.TwoWay;
myBinding2.Source = g;
txttz.SetBinding(TextBox.TextProperty, myBinding2);
Binding myBinding3 = new Binding("format");
myBinding3.Mode = BindingMode.TwoWay;
myBinding3.Source = g;
txtformat.SetBinding(TextBox.TextProperty, myBinding3);
Binding descbinding = new Binding("Description");
descbinding.Mode = BindingMode.TwoWay;
descbinding.Source = g;
txtdesc.SetBinding(TextBox.TextProperty, descbinding);
return base.ToString();
}
开发者ID:julianobarbosa,项目名称:integradesigner,代码行数:27,代码来源:SayUnixTimeProperty.xaml.cs
示例5: AutoScrollHandler
public AutoScrollHandler(System.Windows.Controls.ListBox target)
{
Target = target;
Binding B = new Binding("ItemsSource");
B.Source = Target;
BindingOperations.SetBinding(this, ItemsSourceProperty, B);
}
开发者ID:Kayomani,项目名称:FAP,代码行数:7,代码来源:ListBoxAutoScroll.cs
示例6: MemberPickerDlg
public MemberPickerDlg(IFileTreeView globalFileTreeView, IFileTreeView newFileTreeView, IImageManager imageManager) {
InitializeComponent();
DataContextChanged += (s, e) => {
var data = DataContext as MemberPickerVM;
if (data != null) {
data.OpenAssembly = new OpenAssembly(globalFileTreeView.FileManager);
data.PropertyChanged += MemberPickerVM_PropertyChanged;
}
};
openImage.Source = imageManager.GetImage(GetType().Assembly, "Open", BackgroundType.DialogWindow);
var treeView = (Control)newFileTreeView.TreeView.UIObject;
cpTreeView.Content = treeView;
Validation.SetErrorTemplate(treeView, (ControlTemplate)FindResource("noRedBorderOnValidationError"));
treeView.AllowDrop = false;
treeView.BorderThickness = new Thickness(1);
var binding = new Binding {
ValidatesOnDataErrors = true,
ValidatesOnExceptions = true,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
Path = new PropertyPath("SelectedItem"),
Mode = BindingMode.TwoWay,
};
treeView.SetBinding(Selector.SelectedItemProperty, binding);
var cmd = new RelayCommand(a => {
searchTextBox.SelectAll();
searchTextBox.Focus();
});
InputBindings.Add(new KeyBinding(cmd, Key.E, ModifierKeys.Control));
InputBindings.Add(new KeyBinding(cmd, Key.F, ModifierKeys.Control));
}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:33,代码来源:MemberPickerDlg.xaml.cs
示例7: SetBinding
public static void SetBinding (
DependencyObject target,
DependencyProperty property,
Binding binding ) {
throw new NotImplementedException ( );
}
开发者ID:bbqchickenrobot,项目名称:WPFLight,代码行数:7,代码来源:BindingOperations.cs
示例8: AsymmetricObjects
private void AsymmetricObjects()
{
Console.WriteLine("Asymmetric");
Console.WriteLine("----------");
// bind
var numberBinding = new Binding("Number") {Source = _guineaPig};
var nameBinding = new Binding("FullName") {Source = _guineaPig};
_subjectUnderTest.Number.SetBinding(System.Windows.Controls.TextBox.TextProperty, numberBinding);
_subjectUnderTest.FullName.SetBinding(System.Windows.Controls.TextBox.TextProperty, nameBinding);
var testDuration = new Stopwatch();
testDuration.Start();
RunAsymmetric();
testDuration.Stop();
Console.WriteLine(
string.Format("Write to {0}: {1} msec.", _subjectUnderTest.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));
testDuration.Restart();
RunReverseAsymmetric();
testDuration.Stop();
Console.WriteLine(
string.Format("Write to {0}: {1} msec.", _guineaPig.GetType().Name, testDuration.ElapsedMilliseconds.ToString("#,###")));
Console.WriteLine();
}
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:26,代码来源:WpfTester.cs
示例9: MainWindow
/// <summary>
/// Initializes a new instance of the <see cref="MainWindow"/> class.
/// </summary>
public MainWindow()
{
this.InitializeComponent();
// initialize the sensor chooser and UI
this.sensorChooser = new KinectSensorChooser();
this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
this.sensorChooser.Start();
// Bind the sensor chooser's current sensor to the KinectRegion
var regionSensorBinding = new Binding("Kinect") { Source = this.sensorChooser };
BindingOperations.SetBinding(this.kinectRegion, KinectRegion.KinectSensorProperty, regionSensorBinding);
// Clear out placeholder content
this.wrapPanel.Children.Clear();
// Add in display content
for (var index = 0; index < 300; ++index)
{
var button = new KinectTileButton { Label = (index + 1).ToString(CultureInfo.CurrentCulture) };
this.wrapPanel.Children.Add(button);
}
// Bind listener to scroll viewer scroll position change, and check scroll viewer position
this.UpdatePagingButtonState();
scrollViewer.ScrollChanged += (o, e) => this.UpdatePagingButtonState();
}
开发者ID:flyfj,项目名称:KinectStudio,代码行数:31,代码来源:MainWindow.xaml.cs
示例10: 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
示例11: UserControl_DataContextChanged
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var selectedItem = (DataContext as IEntityGridViewModel).SelectedItem;
if (selectedItem == null)
return;
Type type = selectedItem.GetType();
var relationshipProperties = type.GetProperties()
.Where(t =>
t.Name != "Relationships" &&
t.GetGetMethod().IsVirtual &&
t.PropertyType.IsGenericType &&
t.PropertyType.GetGenericTypeDefinition() == typeof(ICollection<>))
.ToList();
foreach (var property in relationshipProperties)
{
//Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };
TextBlock textBlock = new TextBlock() { Text = property.Name };
//BindingOperations.SetBinding(textBlock, TextBlock.TextProperty, binding);
relatedEntitiesStackPanel.Children.Add(textBlock);
Binding binding = new Binding() { Path = new PropertyPath("SelectedItem." + property.Name), Source = this.DataContext };
DataGridControl listView = new DataGridControl();
var value = property.GetValue(selectedItem) as System.Collections.IEnumerable;
//listView.ItemsSource = value;
BindingOperations.SetBinding(listView, DataGrid.ItemsSourceProperty, binding);
relatedEntitiesStackPanel.Children.Add(listView);
}
}
开发者ID:jweimann,项目名称:webdb,代码行数:35,代码来源:RelatedEntitiesView.xaml.cs
示例12: ToString
public override string ToString()
{
g = (ExtenSpy)base.Tag;
Binding myBinding = new Binding("extension");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Source = g;
txtext.SetBinding(TextBox.TextProperty, myBinding);
Binding myBinding2 = new Binding("context");
myBinding2.Mode = BindingMode.TwoWay;
myBinding2.Source = g;
txtcontext.SetBinding(TextBox.TextProperty, myBinding2);
Binding myBinding3 = new Binding("options");
myBinding3.Mode = BindingMode.TwoWay;
myBinding3.Source = g;
txtopt.SetBinding(TextBox.TextProperty, myBinding3);
Binding descbinding = new Binding("Description");
descbinding.Mode = BindingMode.TwoWay;
descbinding.Source = g;
txtdesc.SetBinding(TextBox.TextProperty, descbinding);
return base.ToString();
}
开发者ID:julianobarbosa,项目名称:integradesigner,代码行数:28,代码来源:ExtenSpyProperty.xaml.cs
示例13: CreateWidgetControl
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
{
var buttonHolder = widgetViewModel as EntityButtonWidgetViewModel;
var ret = new FlexButton.FlexButton { DataContext = buttonHolder, ContextMenu = contextMenu, CommandParameter = buttonHolder };
var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var captionBinding = new Binding("Settings.Caption") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var commandBinding = new Binding("ItemClickedCommand") { Source = buttonHolder, Mode = BindingMode.OneWay };
var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay };
var rotateTransform = new Binding("RotateTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };
ret.SetBinding(InkCanvas.LeftProperty, xBinding);
ret.SetBinding(InkCanvas.TopProperty, yBinding);
ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);
ret.SetBinding(ContentControl.ContentProperty, captionBinding);
ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding);
ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding);
ret.SetBinding(ButtonBase.CommandProperty, commandBinding);
ret.SetBinding(FrameworkElement.LayoutTransformProperty, rotateTransform);
//ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding);
return ret;
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:30,代码来源:EntityButtonWidgetCreator.cs
示例14: CreateWidgetControl
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
{
var buttonHolder = widgetViewModel as TicketExplorerViewModel;
var ret = new TicketExplorerView { DataContext = buttonHolder, ContextMenu = contextMenu };
var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var radiusBinding = new Binding("CornerRadius") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var buttonColorBinding = new Binding("ButtonColor") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var enabledBinding = new Binding("IsEnabled") { Source = buttonHolder, Mode = BindingMode.OneWay };
var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };
ret.SetBinding(InkCanvas.LeftProperty, xBinding);
ret.SetBinding(InkCanvas.TopProperty, yBinding);
ret.SetBinding(FrameworkElement.HeightProperty, heightBinding);
ret.SetBinding(FrameworkElement.WidthProperty, widthBinding);
//ret.SetBinding(FlexButton.FlexButton.CornerRadiusProperty, radiusBinding);
//ret.SetBinding(FlexButton.FlexButton.ButtonColorProperty, buttonColorBinding);
//ret.SetBinding(UIElement.RenderTransformProperty, transformBinding);
//ret.SetBinding(UIElement.IsEnabledProperty, enabledBinding);
return ret;
}
开发者ID:yemreguney,项目名称:SambaPOS-3,代码行数:26,代码来源:TicketExplorerWidgetCreator.cs
示例15: BaseBox
public BaseBox()
{
// テキストボックスの高さを固定
this.Height = 23;
// 文字の垂直方向の配置
this.VerticalContentAlignment = VerticalAlignment.Center;
// 折り返し表示の禁止
this.TextWrapping = System.Windows.TextWrapping.NoWrap;
// Enterによるフォーカス移動
this.SetValue(EnterThenNextFocus.EnterThenNextFocusProperty, true);
// フォーカス取得時にテキスト全選択
this.SetValue(SelectOnFocus.SelectOnFocusProperty, true);
// バインディングなどの設定
this.Initialized += delegate
{
// エラー発生時の表示テンプレートの設定
ControlTemplate ErrTemplate = (ControlTemplate)FindResource("ErrTemplate");
this.SetValue(Validation.ErrorTemplateProperty, ErrTemplate);
// バインディングの設定
Binding oldBinding = BindingOperations.GetBinding(this, TextBox.TextProperty);
if (oldBinding == null) return;
BindingOperations.ClearBinding(this, TextBox.TextProperty);
Binding newBinding = new Binding(oldBinding.Path.Path)
{
StringFormat = DisplayFormat.GetDisplayFormat(this),
Mode = BindingMode.TwoWay,
TargetNullValue = String.Empty
};
BindingOperations.SetBinding(this, TextBox.TextProperty, newBinding);
};
}
开发者ID:higeneko760414,项目名称:WPFCommon,代码行数:33,代码来源:BaseBox.cs
示例16: SetBindingObject
public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
{
Type propertyType = source.GetType().GetProperty(propertyName).PropertyType;
PropertyInfo info = source.GetType().GetProperty("RangeList");
FANumberRangeRule rangeRule = null;
if (info != null)
{
object value = info.GetValue(source, null);
if (value != null)
{
FALibrary.Utility.SerializableDictionary<string, FARange> dic =
(FALibrary.Utility.SerializableDictionary<string, FARange>)value;
if (dic.ContainsKey(propertyName))
{
rangeRule = new FANumberRangeRule(propertyType);
rangeRule.Range = dic[propertyName];
obj.Tag = rangeRule;
obj.Style = (Style)App.Current.Resources["TextBoxErrorStyle"];
}
}
}
Binding bd = new Binding(propertyName);
bd.Source = source;
bd.Mode = mode;
bd.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
if (rangeRule != null)
{
bd.NotifyOnValidationError = true;
bd.ValidationRules.Add(rangeRule);
}
obj.SetBinding(dp, bd);
}
开发者ID:vesteksoftware,项目名称:VT8642,代码行数:34,代码来源:BindingUtility.cs
示例17: WatermarkAdorner
/// <summary>
/// Initializes a new instance of the <see cref="WatermarkAdorner"/> class
/// </summary>
/// <param name="adornedElement"><see cref="UIElement"/> to be adorned</param>
/// <param name="watermark">The watermark</param>
public WatermarkAdorner(UIElement adornedElement, object watermark)
: base(adornedElement)
{
IsHitTestVisible = false;
contentPresenter = new ContentPresenter
{
Content = watermark,
Opacity = 0.5,
Margin = new Thickness(Control.Margin.Left + Control.Padding.Left, Control.Margin.Top + Control.Padding.Top, 0, 0)
};
if (Control is ItemsControl && !(Control is ComboBox))
{
contentPresenter.VerticalAlignment = VerticalAlignment.Center;
contentPresenter.HorizontalAlignment = HorizontalAlignment.Center;
}
// Hide the control adorner when the adorned element is hidden
var binding = new Binding("IsVisible")
{
Source = adornedElement,
Converter = new BooleanToVisibilityConverter()
};
SetBinding(VisibilityProperty, binding);
}
开发者ID:Slesa,项目名称:Poseidon,代码行数:31,代码来源:WatermarkAdorner.cs
示例18: IntegerSlider
public IntegerSlider(Core.VplControl hostCanvas)
: base(hostCanvas)
{
AddOutputPortToNode("Number", typeof(int));
SliderExpanderInteger expander = new SliderExpanderInteger
{
Style = hostCanvas.FindResource("ExpanderSliderStyleInteger") as Style,
SliderValue = 5,
SliderMax = 10,
SliderMin = 0,
SliderStep = 1
};
var b2 = new Binding("Data")
{
Mode = BindingMode.OneWayToSource,
Source = OutputPorts[0]
};
expander.SetBinding(SliderExpanderInteger.SliderValueProperty, b2);
Name = "Integer slider";
AddControlToNode(expander);
}
开发者ID:aquarius20th,项目名称:CSharp_TUM.CMS.VPLControl,代码行数:25,代码来源:IntegerSlider.cs
示例19: ToString
public override string ToString()
{
s = (Rand)base.Tag;
Binding myBinding = new Binding("result");
myBinding.Mode = BindingMode.TwoWay;
myBinding.Source = s;
txtres.SetBinding(TextBox.TextProperty, myBinding);
Binding myBinding2 = new Binding("min");
myBinding2.Mode = BindingMode.TwoWay;
myBinding2.Source = s;
txtmin.SetBinding(TextBox.TextProperty, myBinding2);
Binding myBinding3 = new Binding("max");
myBinding3.Mode = BindingMode.TwoWay;
myBinding3.Source = s;
txtmax.SetBinding(TextBox.TextProperty, myBinding3);
Binding descbinding = new Binding("Description");
descbinding.Mode = BindingMode.TwoWay;
descbinding.Source = s;
txtdesc.SetBinding(TextBox.TextProperty, descbinding);
return base.ToString();
}
开发者ID:julianobarbosa,项目名称:integradesigner,代码行数:26,代码来源:RandProperty.xaml.cs
示例20: UpdateContent
private void UpdateContent()
{
if (panel == null)
return;
panel.Children.Clear();
if (Value == null)
return;
var enumValues = Enum.GetValues(Value.GetType()).FilterOnBrowsableAttribute();
var converter = new EnumToBooleanConverter { EnumType = Value.GetType() };
var relativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(RadioButtonList), 1);
var descriptionConverter = new EnumDescriptionConverter();
foreach (var itemValue in enumValues )
{
var rb = new RadioButton { Content = descriptionConverter.Convert(itemValue, typeof(string), null, CultureInfo.CurrentCulture) };
// rb.IsChecked = Value.Equals(itemValue);
var isCheckedBinding = new Binding("Value")
{
Converter = converter,
ConverterParameter = itemValue,
Mode = BindingMode.TwoWay,
RelativeSource = relativeSource
};
rb.SetBinding(ToggleButton.IsCheckedProperty, isCheckedBinding);
var itemMarginBinding = new Binding("ItemMargin") { RelativeSource = relativeSource };
rb.SetBinding(MarginProperty, itemMarginBinding);
panel.Children.Add(rb);
}
}
开发者ID:hpbaotho,项目名称:sambapos,代码行数:35,代码来源:RadioButtonList.cs
注:本文中的System.Windows.Data.Binding类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论