本文整理汇总了C#中System.Windows.Data.MultiBinding类的典型用法代码示例。如果您正苦于以下问题:C# MultiBinding类的具体用法?C# MultiBinding怎么用?C# MultiBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiBinding类属于System.Windows.Data命名空间,在下文中一共展示了MultiBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestUserControl
public TestUserControl()
{
InitializeComponent();
return;
KeepPreviewColor = false;
ColorsBox.ItemsSource = typeof(Colors).GetProperties();
#region Binding Color to sliders
MultiBinding mb = new MultiBinding();
mb.Converter = new RgbToColorConverter();
mb.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
mb.Mode = BindingMode.TwoWay;
Binding bb = new Binding("Value");
bb.ElementName = "R";
bb.Mode = BindingMode.TwoWay;
mb.Bindings.Add(bb);
bb = new Binding("Value");
bb.ElementName = "G";
bb.Mode = BindingMode.TwoWay;
mb.Bindings.Add(bb);
bb = new Binding("Value");
bb.ElementName = "B";
bb.Mode = BindingMode.TwoWay;
mb.Bindings.Add(bb);
this.SetBinding(ColorProperty, mb);
#endregion
}
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:34,代码来源:TestUserControl.xaml.cs
示例2: PieChartLegendItem
public PieChartLegendItem(PieChartItem pieChartItem, PieChart chart)
{
ResourceDictionary dict = (ResourceDictionary)Application.LoadComponent(new Uri("/DynamicDataDisplay.Markers;component/PieChart files/PieChartResources.xaml", UriKind.Relative));
//NewLegend.SetChart(this, pieChartItem);
DataContext = pieChartItem.DataContext;
Style selfStyle = (Style)dict[GetType()];
Style = selfStyle;
Binding fillBinding = new Binding { Path = new PropertyPath("Background"), Source = pieChartItem };
SetBinding(BackgroundProperty, fillBinding);
if (chart.DependentValueBinding != null)
{
SetBinding(NewLegend.DescriptionProperty, chart.DependentValueBinding);
}
bool setTooltipBinding = !String.IsNullOrEmpty(chart.IndependentValuePath) && !String.IsNullOrEmpty(chart.DependentValuePath);
if (setTooltipBinding)
{
MultiBinding tooltipBinding = new MultiBinding { Converter = new PieLegendItemTooltipConverter() };
tooltipBinding.Bindings.Add(chart.DependentValueBinding);
tooltipBinding.Bindings.Add(chart.IndependentValueBinding);
SetBinding(ToolTipService.ToolTipProperty, tooltipBinding);
}
}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:27,代码来源:PieChartLegendItem.cs
示例3: ReadOnlyAllAnswersControl
public ReadOnlyAllAnswersControl()
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(this))
{
this.HandleDesignTimeView();
}
//this.mPartialsForQuestion.SetBinding(UserControl.VisibilityProperty, QuestionControl.PartialsIsEmptyToVisibilityBinding);
// Set up the No Questions Yet message
FrameworkElement noQuestionsMessage = this.mNoQuestionsMessage;
MultiBinding noQuestionsBinding = new MultiBinding();
noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") });
noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") });
noQuestionsBinding.Converter = new NoQuestionsMessageVisibilityConverter();
noQuestionsMessage.SetBinding(UIElement.VisibilityProperty, noQuestionsBinding);
// Set up the allQuestionsClosedMessage
MultiBinding allQuestionsClosedBinding = new MultiBinding();
allQuestionsClosedBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") });
allQuestionsClosedBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") });
allQuestionsClosedBinding.Converter = new AllQuestionsClosedMessageVisibilityConverter();
this.mAllQuestionsClosedMessage.SetBinding(UIElement.VisibilityProperty, allQuestionsClosedBinding);
}
开发者ID:bignis,项目名称:Trivia,代码行数:34,代码来源:ReadOnlyAllAnswersControl.xaml.cs
示例4: MultiValidatorPanel
public MultiValidatorPanel(UIElement content, UIElement[] elements, DependencyProperty property, IValidate validation, ValidationAggregationType type)
{
Content = content;
MultiBinding multiBinding = new MultiBinding();
switch (type)
{
case ValidationAggregationType.And:
multiBinding.Converter = new AndValidationConverter(validation);
break;
case ValidationAggregationType.Or:
multiBinding.Converter = new OrValidationConverter(validation);
break;
}
for (var i = 0; i < elements.Length; ++i)
{
Binding b =
new Binding()
{
Source = elements[i],
Path = new PropertyPath(property.Name),
Mode = BindingMode.OneWay
};
multiBinding.Bindings.Add(b);
}
this.SetBinding(ValidProperty, multiBinding);
}
开发者ID:ianeller-romey,项目名称:CompJS_TTTD,代码行数:28,代码来源:MultiValidatorPanel.cs
示例5: StyleSelectionMenuItemList
public StyleSelectionMenuItemList()
{
ItemsSource = ItemsSource = AvailableStyles.Instance;
var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) };
var headerBinding = new Binding();
var headerSetter = new Setter(HeaderProperty, headerBinding);
checkableMenuItemStyle.Setters.Add(headerSetter);
var isCheckableSetter = new Setter(IsCheckableProperty, true);
checkableMenuItemStyle.Setters.Add(isCheckableSetter);
ICommand command = new RelayCommand(SelectStyle);
var commandSetter = new Setter(CommandProperty, command);
checkableMenuItemStyle.Setters.Add(commandSetter);
var commandParamBinding = new Binding();
var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding);
checkableMenuItemStyle.Setters.Add(commandParamSetter);
var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay };
isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay });
isCheckedMultiBinding.Bindings.Add(new Binding("SelectedStyle") { Source = AvailableStyles.Instance, Mode = BindingMode.OneWay });
var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding);
checkableMenuItemStyle.Setters.Add(isCheckedSetter);
Resources.Add(typeof(MenuItem), checkableMenuItemStyle);
}
开发者ID:ChronosWS,项目名称:WPFSharp.Globalizer,代码行数:29,代码来源:StyleSelectionMenuItemList.cs
示例6: QuestionListControl
public QuestionListControl()
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(this))
{
this.HandleDesignTimeView();
}
// Set up the divider
FrameworkElement divider = this.mQuestionsDivider;
MultiBinding dividerBinding = new MultiBinding();
dividerBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") });
dividerBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") });
dividerBinding.Converter = new QuestionsDividerVisibilityConverter();
divider.SetBinding(UIElement.VisibilityProperty, dividerBinding);
// Set up the No Questions Yet message
FrameworkElement noQuestionsMessage = this.mNoQuestionsMessage;
MultiBinding noQuestionsBinding = new MultiBinding();
noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("OpenQuestions.IsEmpty") });
noQuestionsBinding.Bindings.Add(new Binding() { Path = new PropertyPath("ClosedQuestions.IsEmpty") });
noQuestionsBinding.Converter = new NoQuestionsMessageVisibilityConverter();
noQuestionsMessage.SetBinding(UIElement.VisibilityProperty, noQuestionsBinding);
}
开发者ID:bignis,项目名称:Trivia,代码行数:33,代码来源:QuestionListControl.xaml.cs
示例7: ProvideValue
public override object ProvideValue(IServiceProvider serviceProvider)
{
if (this.Key == null && this.KeyBinding == null)
throw new ArgumentException("Either Key or KeyBinding must be set");
if (this.Key != null && this.KeyBinding != null)
throw new ArgumentException("Either Key or KeyBinding must be set, but not both");
if (this.ValueBinding != null && this.ValueBindings != null)
throw new ArgumentException("ValueBinding and ValueBindings may not be set at the same time");
// Most of these conditions are redundent, according to the assertions above. However I'll still state them,
// for clarity.
// A static key, and no values
if (this.Key != null && this.KeyBinding == null && this.ValueBinding == null && this.ValueBindings == null)
{
// Just returning a string!
return Localizer.Translate(this.Key);
}
// A static key, and a single value
if (this.Key != null && this.KeyBinding == null && this.ValueBinding != null && this.ValueBindings == null)
{
var converter = new StaticKeySingleValueConverter() { Key = this.Key, Converter = this.ValueBinding.Converter };
this.ValueBinding.Converter = converter;
return this.ValueBinding.ProvideValue(serviceProvider);
}
// A static key, and multiple values
if (this.Key != null && this.KeyBinding == null && this.ValueBinding == null && this.ValueBindings != null)
{
var converter = new StaticKeyMultipleValuesConverter() { Key = this.Key, Converter = this.ValueBindings.Converter };
this.ValueBindings.Converter = converter;
return this.ValueBindings.ProvideValue(serviceProvider);
}
// A bound key, no values
if (this.Key == null && this.KeyBinding != null && this.ValueBinding == null && this.ValueBindings == null)
{
var converter = new BoundKeyNoValuesConverter() { Converter = this.KeyBinding.Converter };
this.KeyBinding.Converter = converter;
return this.KeyBinding.ProvideValue(serviceProvider);
}
// A bound key, and one value
if (this.Key == null && this.KeyBinding != null && this.ValueBinding != null && this.ValueBindings == null)
{
var converter = new BoundKeyWithValuesConverter();
var multiBinding = new MultiBinding() { Converter = converter };
multiBinding.Bindings.Add(this.KeyBinding);
multiBinding.Bindings.Add(this.ValueBinding);
return multiBinding.ProvideValue(serviceProvider);
}
// A bound key, and multiple values
if (this.Key == null && this.KeyBinding != null && this.ValueBinding == null && this.ValueBindings != null)
{
var converter = new BoundKeyWithValuesConverter() { ValuesConverter = this.ValueBindings.Converter };
this.ValueBindings.Bindings.Insert(0, this.KeyBinding);
this.ValueBindings.Converter = converter;
return this.ValueBindings.ProvideValue(serviceProvider);
}
throw new Exception("Should never get here");
}
开发者ID:johnhk,项目名称:SyncTrayzor,代码行数:59,代码来源:LocExtension.cs
示例8: ProvideValue
public override object ProvideValue(IServiceProvider rpServiceProvider)
{
var rResult = new MultiBinding() { Converter = CoreConverter.Instance };
rResult.Bindings.Add(new Binding() { RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ListView), 1) });
rResult.Bindings.Add(new Binding());
return rResult.ProvideValue(rpServiceProvider);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:8,代码来源:ItemIndexExtension.cs
示例9: ProvideValue
public override object ProvideValue(IServiceProvider rpServiceProvider)
{
var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance };
rResult.Bindings.Add(new Binding("ModifierKeys.Value") { Source = Preference.Instance.Other.PanicKey });
rResult.Bindings.Add(new Binding("Key.Value") { Source = Preference.Instance.Other.PanicKey });
return rResult.ProvideValue(rpServiceProvider);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:8,代码来源:PanicKeyPreferenceExtension.cs
示例10: MultiBindingExpression
/// <summary>
/// Initializes a new instance of the <see cref="MultiBindingExpression"/> class and applies it to the given target.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="multiBinding">The parent <see cref="MultiBinding"/></param>
public MultiBindingExpression(DependencyObject target, MultiBinding multiBinding)
{
if (target == null) throw new ArgumentNullException("target");
if (multiBinding == null) throw new ArgumentNullException("multiBinding");
Target = target;
MultiBinding = multiBinding;
ApplyToTarget();
}
开发者ID:JeanNguon,项目名称:Projet,代码行数:14,代码来源:MultiBindingExpression.cs
示例11: MultiBindingExpression
//------------------------------------------------------
//
// Constructors
//
//------------------------------------------------------
/// <summary> Constructor </summary>
private MultiBindingExpression(MultiBinding binding, BindingExpressionBase owner)
: base(binding, owner)
{
int count = binding.Bindings.Count;
// reduce repeated allocations
_tempValues = new object[count];
_tempTypes = new Type[count];
}
开发者ID:JianwenSun,项目名称:cc,代码行数:16,代码来源:MultiBindingExpression.cs
示例12: MediaBrowser
public MediaBrowser()
{
InitializeComponent();
((FrameworkElement)this.Content).DataContext = this;
MultiBinding mb = new MultiBinding() { Converter = new MediaBrowserFilterConverter(this) };
mb.Bindings.Add(new Binding("SourceData.PlaylistItems") { Source = this });
mb.Bindings.Add(new Binding("Text") { Source = textBox });
BindingOperations.SetBinding(this, SelectedDataProperty, mb);
}
开发者ID:haha01haha01,项目名称:HaMusic,代码行数:9,代码来源:MediaBrowser.xaml.cs
示例13: ProvideValue
public override object ProvideValue(IServiceProvider rpServiceProvider)
{
var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = Converter.Instance, ConverterParameter = r_Type, StringFormat = StringFormat };
rResult.Bindings.Add(new Binding(r_IDPath));
rResult.Bindings.Add(new Binding(r_OriginalTextPath));
rResult.Bindings.Add(new Binding(nameof(StringResources.Instance.Extra)) { Source = StringResources.Instance });
return rResult.ProvideValue(rpServiceProvider);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun-Fx4,代码行数:9,代码来源:ExtraStringResourceExtension.cs
示例14: GetStatBinding
private static MultiBinding GetStatBinding(BattleEntity source, BattleEntityStatCalculationData calculationData)
{
var statBinding = new MultiBinding { Converter = new BattleEntityStatCalculationConverter() };
statBinding.Bindings.Add(new Binding { Source = calculationData.CalculationFunction });
foreach (var bindingPath in calculationData.BindingPaths)
{
statBinding.Bindings.Add(new Binding(bindingPath) { Source = source });
}
return statBinding;
}
开发者ID:VOChris,项目名称:VOStudios,代码行数:10,代码来源:BattleEntityStatCalculationUtility.cs
示例15: SetMultiBinding
private void SetMultiBinding()
{
Binding b1 = new Binding("Text") { Source = this.txtBox1 };
Binding b2 = new Binding("Text") { Source = this.txtBox2 };
Binding b3 = new Binding("Text") { Source = this.txtBox3 };
Binding b4 = new Binding("Text") { Source = this.txtBox4 };
MultiBinding mb = new MultiBinding { Mode = BindingMode.OneWay, Bindings = { b1, b2, b3, b4 } };
mb.Converter = new LogonMultiBindingConverter();
this.btn1.SetBinding(Button.IsEnabledProperty, mb);
}
开发者ID:BerdyPango,项目名称:Researches,代码行数:10,代码来源:Demo_MultiBinding.xaml.cs
示例16: BattleActionBar
public BattleActionBar()
{
InitializeComponent();
//set up the filled bindings
var percentFilledBinding = new MultiBinding { Converter = new BattleActionBarPercentFilledConverter() };
percentFilledBinding.Bindings.Add(new Binding("Value") { Source = this });
percentFilledBinding.Bindings.Add(new Binding("MaximumValue") { Source = this });
percentFilledBinding.Bindings.Add(new Binding("ActualHeight") { Source = this });
BindingOperations.SetBinding(this, PercentFilledProperty, percentFilledBinding);
}
开发者ID:VOChris,项目名称:VOStudios,代码行数:11,代码来源:BattleActionBar.xaml.cs
示例17: ProvideValue
public override object ProvideValue(IServiceProvider rpServiceProvider)
{
if (!StringResources.Instance.IsLoaded)
return Path;
var rResult = new MultiBinding() { Converter = r_Converter, ConverterParameter = Prefix, StringFormat = StringFormat, Mode = Mode, TargetNullValue = TargetNullValue };
rResult.Bindings.Add(new Binding(Path));
rResult.Bindings.Add(new Binding(nameof(StringResources.Instance.Main)) { Source = StringResources.Instance });
return rResult.ProvideValue(rpServiceProvider);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:12,代码来源:EnumToStringResourceExtension.cs
示例18: ProvideValue
public override object ProvideValue(IServiceProvider rpServiceProvider)
{
var rResult = new MultiBinding() { Mode = BindingMode.OneWay, Converter = CoreConverter.Instance };
rResult.Bindings.Add(new Binding() { Path = new PropertyPath(MetroWindow.ScreenOrientationProperty), RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MetroWindow), 1) });
rResult.Bindings.Add(new Binding("Layout.LandscapeDock") { Source = Preference.Current });
rResult.Bindings.Add(new Binding("Layout.PortraitDock") { Source = Preference.Current });
rResult.Bindings.Add(new Binding() { RelativeSource = RelativeSource.Self });
if (Converter != null)
rResult.ConverterParameter = Tuple.Create(Converter, ConverterParameter);
return rResult.ProvideValue(rpServiceProvider);
}
开发者ID:amatukaze,项目名称:IntelligentNavalGun-Fx4,代码行数:13,代码来源:CurrentDockExtension.cs
示例19: SetTransactionInfo
partial void SetTransactionInfo(TransactionInfo transactionInfo)
{
//This instance of TransactionInfo acts as a "shared model" between this view and the order details view.
//The scenario says that these 2 views are decoupled, so they don't share the view model, they are only tied
//with this TransactionInfo
this.orderDetailsViewModel.TransactionInfo = transactionInfo;
//Bind the CompositeOrderView header to a string representation of the TransactionInfo shared instance (we expect the details view model to modify it from user interaction).
MultiBinding binding = new MultiBinding();
binding.Bindings.Add(new Binding("TransactionType") { Source = transactionInfo });
binding.Bindings.Add(new Binding("TickerSymbol") { Source = transactionInfo });
binding.Converter = new OrderHeaderConverter();
BindingOperations.SetBinding(this, HeaderInfoProperty, binding);
}
开发者ID:selvendiranj,项目名称:compositewpf-copy,代码行数:14,代码来源:OrderCompositeViewModel.Desktop.cs
示例20: ProvideValue
public override object ProvideValue(IServiceProvider serviceProvider)
{
var resourceKeyBinding = new Binding()
{
BindsDirectlyToSource = BindsDirectlyToSource,
Mode = BindingMode.OneWay,
Path = Path,
XPath = XPath,
};
//Binding throws an InvalidOperationException if we try setting all three
// of the following properties simultaneously: thus make sure we only set one
if (ElementName != null)
{
resourceKeyBinding.ElementName = ElementName;
}
else if (RelativeSource != null)
{
resourceKeyBinding.RelativeSource = RelativeSource;
}
else if (Source != null)
{
resourceKeyBinding.Source = Source;
}
var targetElementBinding = new Binding();
targetElementBinding.RelativeSource = new RelativeSource()
{
Mode = RelativeSourceMode.Self
};
var multiBinding = new MultiBinding();
multiBinding.Bindings.Add(targetElementBinding);
multiBinding.Bindings.Add(resourceKeyBinding);
// If we set the Converter on resourceKeyBinding then, for some reason,
// MultiBinding wants it to produce a value matching the Target Type of the MultiBinding
// When it doesn't, it throws a wobbly and passes DependencyProperty.UnsetValue through
// to our MultiBinding ValueConverter. To circumvent this, we do the value conversion ourselves.
// See http://social.msdn.microsoft.com/forums/en-US/wpf/thread/af4a19b4-6617-4a25-9a61-ee47f4b67e3b
multiBinding.Converter = new ResourceKeyToResourceConverter()
{
ResourceKeyConverter = Converter,
ConverterParameter = ConverterParameter,
StringFormat = StringFormat,
};
return multiBinding.ProvideValue(serviceProvider);
}
开发者ID:BDDCloud,项目名称:Amazon.OrderFulfillment,代码行数:49,代码来源:ResourceKeyBindingExtension.cs
注:本文中的System.Windows.Data.MultiBinding类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论