当前位置: 首页>>代码示例>>C#>>正文


C# IDataDescriptor.Attach方法代码示例

本文整理汇总了C#中IDataDescriptor.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# IDataDescriptor.Attach方法的具体用法?C# IDataDescriptor.Attach怎么用?C# IDataDescriptor.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataDescriptor的用法示例。


在下文中一共展示了IDataDescriptor.Attach方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BindingDependency

 /// <summary>
 /// Creates a new <see cref="BindingDependency"/> object.
 /// </summary>
 /// <param name="sourceDd">Souce data descriptor for the dependency.</param>
 /// <param name="targetDd">Target data descriptor for the dependency.</param>
 /// <param name="autoAttachToSource">If set to <c>true</c>, the new dependency object will be
 /// automatically attached to the <paramref name="sourceDd"/> data descriptor. This means it will
 /// capture changes from it and reflect them on the <paramref name="targetDd"/> data descriptor.</param>
 /// <param name="updateSourceTrigger">This parameter controls, which target object event makes this
 /// binding dependency copy the target value to the <paramref name="sourceDd"/> data descriptor.
 /// If set to <see cref="UpdateSourceTrigger.PropertyChanged"/>, the new binding dependency object
 /// will automatically attach to property changes of the <paramref name="targetDd"/> data descriptor and
 /// reflect the changed value to the <paramref name="sourceDd"/> data descriptor. If set to
 /// <see cref="UpdateSourceTrigger.LostFocus"/>, the new binding dependency will attach to the
 /// <see cref="UIElement.EventOccured"/> event of the <paramref name="parentUiElement"/> object.
 /// If set to <see cref="UpdateSourceTrigger.Explicit"/>, the new binding dependency won't attach to
 /// the target at all.</param>
 /// <param name="parentUiElement">The parent <see cref="UIElement"/> of the specified <paramref name="targetDd"/>
 /// data descriptor. This parameter is only used to attach to the lost focus event if
 /// <paramref name="updateSourceTrigger"/> is set to <see cref="UpdateSourceTrigger.LostFocus"/>.</param>
 /// <param name="customValueConverter">Set a custom value converter with this parameter. If this parameter
 /// is set to <c>null</c>, the default <see cref="TypeConverter"/> will be used.</param>
 /// <param name="customValueConverterParameter">Parameter to be used in the custom value converter, if one is
 /// set.</param>
 public BindingDependency(IDataDescriptor sourceDd, IDataDescriptor targetDd, bool autoAttachToSource,
     UpdateSourceTrigger updateSourceTrigger, UIElement parentUiElement,
     IValueConverter customValueConverter, object customValueConverterParameter)
 {
   _sourceDd = sourceDd;
   _targetDd = targetDd;
   _targetObject = _targetDd.TargetObject as DependencyObject;
   _sourceObject = _sourceDd.TargetObject as DependencyObject;
   _valueConverter = customValueConverter;
   _converterParameter = customValueConverterParameter;
   if (autoAttachToSource && sourceDd.SupportsChangeNotification)
   {
     sourceDd.Attach(OnSourceChanged);
     _attachedToSource = true;
   }
   if (targetDd.SupportsChangeNotification)
   {
     if (updateSourceTrigger == UpdateSourceTrigger.PropertyChanged)
     {
       targetDd.Attach(OnTargetChanged);
       _attachedToTarget = true;
     }
     else if (updateSourceTrigger == UpdateSourceTrigger.LostFocus)
     {
       if (parentUiElement != null)
         parentUiElement.EventOccured += OnTargetElementEventOccured;
       _attachedToLostFocus = parentUiElement;
     }
   }
   // Initially update endpoints
   if (autoAttachToSource)
     UpdateTarget();
   if (updateSourceTrigger != UpdateSourceTrigger.Explicit &&
       !autoAttachToSource) // If we are attached to both, only update one direction
     UpdateSource();
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:60,代码来源:BindingDependency.cs

示例2: InitializeSubItemsSource

 /// <summary>
 /// Initializes the <see cref="ItemsControl.ItemsSource"/> property with the <see cref="SubItemsProvider"/>.
 /// </summary>
 /// <returns><c>true</c>, if the <see cref="ItemsControl.ItemsSource"/> property was changed by this method, else <c>false</c>.</returns>
 protected virtual bool InitializeSubItemsSource()
 {
   SubItemsProvider sip = SubItemsProvider;
   IEnumerable oldItemsSource = ItemsSource;
   if (!_contextChangedAttached)
   {
     ContextChanged += OnContextChanged;
     _contextChangedAttached = true;
   }
   if (_attachedContextSource != null)
     _attachedContextSource.Detach(OnDataContextValueChanged);
   _attachedContextSource = DataContext.EvaluatedSourceValue;
   _attachedContextSource.Attach(OnDataContextValueChanged);
   object context = Context;
   if (context == null)
     return false;
   ItemsSource = sip == null ? null : sip.GetSubItems(context);
   if (oldItemsSource == ItemsSource)
     return false;
   MPF.TryCleanupAndDispose(oldItemsSource);
   CheckExpandable();
   return true;
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:27,代码来源:HeaderedItemsControl.cs

示例3: AttachToSource

 /// <summary>
 /// Attaches a change handler to the specified data descriptor
 /// <paramref name="source"/>, which will be used as binding source.
 /// </summary>
 protected void AttachToSource(IDataDescriptor source)
 {
   if (source != null && source.SupportsChangeNotification)
   {
     _attachedSource = source;
     _attachedSource.Attach(OnBindingSourceChange);
   }
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:12,代码来源:BindingMarkupExtension.cs


注:本文中的IDataDescriptor.Attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。