本文整理汇总了C#中System.Windows.DependencyProperty类的典型用法代码示例。如果您正苦于以下问题:C# DependencyProperty类的具体用法?C# DependencyProperty怎么用?C# DependencyProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyProperty类属于System.Windows命名空间,在下文中一共展示了DependencyProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: SetBinding
internal static void SetBinding(this DependencyObject sourceObject, DependencyObject targetObject, DependencyProperty sourceProperty, DependencyProperty targetProperty)
{
Binding b = new Binding();
b.Source = sourceObject;
b.Path = new PropertyPath(sourceProperty);
BindingOperations.SetBinding(targetObject, targetProperty, b);
}
开发者ID:NALSS,项目名称:Dashboarding,代码行数:7,代码来源:ExtensionMethods.cs
示例3: ImageButton
static ImageButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton),
new FrameworkPropertyMetadata(typeof(ImageButton)));
ImageButton.OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation),
typeof(ImageButton), new FrameworkPropertyMetadata(Orientation.Horizontal,
FrameworkPropertyMetadataOptions.AffectsMeasure));
ImageButton.ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(ImageButton),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender |
FrameworkPropertyMetadataOptions.AffectsMeasure));
ImageButton.IsToolStyleProperty = DependencyProperty.Register("IsToolStyle", typeof(bool), typeof(ImageButton),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender
| FrameworkPropertyMetadataOptions.AffectsArrange));
ImageButton.ContentHorizontalAlignmentProperty = DependencyProperty.Register(
"ContentHorizontalAlignment", typeof(HorizontalAlignment),
typeof(ImageButton), new FrameworkPropertyMetadata(HorizontalAlignment.Center,
FrameworkPropertyMetadataOptions.AffectsRender));
ImageButton.ContentVerticalAlignmentProperty = DependencyProperty.Register(
"ContentVerticalAlignment", typeof(VerticalAlignment),
typeof(ImageButton), new FrameworkPropertyMetadata(VerticalAlignment.Center,
FrameworkPropertyMetadataOptions.AffectsRender));
}
开发者ID:alexsharoff,项目名称:wpf-office-theme,代码行数:27,代码来源:ImageButton.cs
示例4: CoinFlipCounter
static CoinFlipCounter()
{
TossProperty = DependencyProperty.Register("Toss", typeof(Boolean), typeof(CoinFlipCounter), new PropertyMetadata(true));
Image1SourceProperty = DependencyProperty.Register("Image1Source", typeof(String), typeof(CoinFlipCounter), new PropertyMetadata(""));
Image2SourceProperty = DependencyProperty.Register("Image1Source", typeof(String), typeof(CoinFlipCounter), new PropertyMetadata(""));
}
开发者ID:fstn,项目名称:WindowsPhoneApps,代码行数:7,代码来源:CoinFlipCounter.xaml.cs
示例5: ReplaceContent
/// <summary>
/// Replaces the content for a <see cref="DataField"/> with another control and updates the bindings.
/// </summary>
/// <param name="field">The <see cref="DataField"/> whose <see cref="TextBox"/> will be replaced.</param>
/// <param name="newControl">The new control you're going to set as <see cref="DataField.Content" />.</param>
/// <param name="dataBindingProperty">The control's property that will be used for data binding.</param>
/// <param name="bindingSetupFunction">
/// An optional <see cref="Action"/> you can use to change parameters on the newly generated binding before
/// it is applied to <paramref name="newControl"/>
/// </param>
/// <param name="sourceProperty">The source dependency property to use for the binding.</param>
public static void ReplaceContent(this DataField field, FrameworkElement newControl, DependencyProperty dataBindingProperty, Action<Binding> bindingSetupFunction, DependencyProperty sourceProperty)
{
if (field == null)
{
throw new ArgumentNullException("field");
}
if (newControl == null)
{
throw new ArgumentNullException("newControl");
}
// Construct new binding by copying existing one, and sending it to bindingSetupFunction
// for any changes the caller wants to perform
Binding newBinding = field.Content.GetBindingExpression(sourceProperty).ParentBinding.CreateCopy();
if (bindingSetupFunction != null)
{
bindingSetupFunction(newBinding);
}
// Replace field
newControl.SetBinding(dataBindingProperty, newBinding);
field.Content = newControl;
}
开发者ID:jeffhandley,项目名称:RIAServicesValidation,代码行数:36,代码来源:DataFieldExtensions.cs
示例6: FocusScopeManager
static FocusScopeManager()
{
// Must do this explicitly because the default value of the FocusScopePriorityProperty depends on DefaultFocusScopePriority being properly initialized.
FocusScopeManager.DefaultFocusScopePriority = Int32.MaxValue;
FocusScopeManager.FocusScopePriorityProperty = DependencyProperty.RegisterAttached("FocusScopePriority", typeof(int), typeof(FocusScopeManager), new FrameworkPropertyMetadata(FocusScopeManager.DefaultFocusScopePriority, new PropertyChangedCallback(FocusScopeManager.FocusScopePriorityChanged)));
FocusManager.FocusedElementProperty.OverrideMetadata(typeof(FrameworkElement), new PropertyMetadata(null, null, new CoerceValueCallback(FocusScopeManager.FocusManager_CoerceFocusedElement)));
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:FocusScopeManager.cs
示例7: DependencyObjectPropertyDescriptor
/// <summary>
/// Creates a new dependency property descriptor. A note on perf: We don't
/// pass the property descriptor down as the default member descriptor here. Doing
/// so takes the attributes off of the property descriptor, which can be costly if they
/// haven't been accessed yet. Instead, we wait until someone needs to access our
/// Attributes property and demand create the attributes at that time.
/// </summary>
internal DependencyObjectPropertyDescriptor(DependencyProperty dp, Type ownerType)
: base(string.Concat(dp.OwnerType.Name, ".", dp.Name), null)
{
_dp = dp;
_componentType = ownerType;
_metadata = _dp.GetMetadata(ownerType);
}
开发者ID:JianwenSun,项目名称:cc,代码行数:14,代码来源:DependencyObjectPropertyDescriptor.cs
示例8: OriginElement
public OriginElement()
{
FrameworkPropertyMetadata meta = new FrameworkPropertyMetadata();
meta.AffectsRender = true;
OriginProperty = DependencyProperty.Register("Origin", typeof(Point), typeof(OriginElement), meta);
}
开发者ID:RookieOne,项目名称:Adorners,代码行数:7,代码来源:OriginElement.cs
示例9: GetStringValue
//------------------------------------------------------
//
// Internal Methods
//
//-----------------------------------------------------
#region Internal Methods
// Returns non-null string if this value can be converted to a string,
// null otherwise.
internal static string GetStringValue(DependencyProperty property, object propertyValue)
{
string stringValue = null;
// Special cases working around incorrectly implemented type converters
if (property == UIElement.BitmapEffectProperty)
{
return null; // Always treat BitmapEffects as complex value
}
if (property == Inline.TextDecorationsProperty)
{
stringValue = TextDecorationsFixup((TextDecorationCollection)propertyValue);
}
else if (typeof(CultureInfo).IsAssignableFrom(property.PropertyType)) //NumberSubstitution.CultureOverrideProperty
{
stringValue = CultureInfoFixup(property, (CultureInfo)propertyValue);
}
if (stringValue == null)
{
DPTypeDescriptorContext context = new DPTypeDescriptorContext(property, propertyValue);
System.ComponentModel.TypeConverter typeConverter = System.ComponentModel.TypeDescriptor.GetConverter(property.PropertyType);
Invariant.Assert(typeConverter != null);
if (typeConverter.CanConvertTo(context, typeof(string)))
{
stringValue = (string)typeConverter.ConvertTo(
context, System.Globalization.CultureInfo.InvariantCulture, propertyValue, typeof(string));
}
}
return stringValue;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:43,代码来源:DPTypeDescriptorContext.cs
示例10: WPFClickTypeWatch
static WPFClickTypeWatch()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( WPFClickTypeWatch ), new FrameworkPropertyMetadata( typeof( WPFClickTypeWatch ) ) );
ValueProperty = DependencyProperty.Register( "Value", typeof( int ), typeof( WPFClickTypeWatch ) );
DisabledColorProperty = DependencyProperty.Register( "DisabledColor", typeof( LinearGradientBrush ), typeof( WPFClickTypeWatch ) );
IsPausedProperty = DependencyProperty.Register( "IsPaused", typeof( bool ), typeof( WPFClickTypeWatch ) );
}
开发者ID:rit3k,项目名称:ck-certified,代码行数:7,代码来源:WPFClickTypeWatch.cs
示例11: RichTextBlock
static RichTextBlock()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(RichTextBlock), new FrameworkPropertyMetadata(typeof(RichTextBlock)));
InlineProperty = DependencyProperty.Register("RichText", typeof(List<Inline>), typeof(RichTextBlock), new PropertyMetadata(null, new PropertyChangedCallback(OnInlineChanged)));
}
开发者ID:shu2333,项目名称:dnGrep,代码行数:7,代码来源:InlineTextBlock.cs
示例12: ProvideValue
public override object ProvideValue(IServiceProvider serviceProvider)
{
var pvt = serviceProvider as IProvideValueTarget;
if (pvt == null)
{
return null;
}
_frameworkElement = pvt.TargetObject as FrameworkElement;
if (_frameworkElement == null)
{
return this;
}
_target = pvt.TargetProperty as DependencyProperty;
if (_target == null)
{
return this;
}
_frameworkElement.DataContextChanged += FrameworkElement_DataContextChanged;
var proxy = new Proxy();
var binding = new Binding()
{
Source = proxy,
Path = new PropertyPath("Value")
};
// Make sure we don't leak subscriptions
_frameworkElement.Unloaded += (e, v) => _subscription.Dispose();
return binding.ProvideValue(serviceProvider);
}
开发者ID:Evangelink,项目名称:WPF-Rethought,代码行数:34,代码来源:ReactiveBinding.cs
示例13: UpdateBinding
public static void UpdateBinding(this FrameworkElement instance, DependencyProperty prop)
{
var bindingExpression = instance.GetBindingExpression(prop);
if (bindingExpression != null)
bindingExpression.UpdateSource();
}
开发者ID:cpmcgrath,项目名称:Bankr,代码行数:7,代码来源:UIExtensions.cs
示例14: LixeiraProperty
static LixeiraProperty()
{
var metadata = new FrameworkPropertyMetadata((ImageSource)null);
ImageProperty = DependencyProperty.RegisterAttached("Image",
typeof(ImageSource),
typeof(LixeiraProperty), metadata);
}
开发者ID:lhlima,项目名称:CollaborationProjects,代码行数:7,代码来源:LixeiraProperty.cs
示例15: DependencyPropertyChangedEventArgs
internal DependencyPropertyChangedEventArgs(
DependencyProperty property,
PropertyMetadata metadata,
bool isAValueChange,
EffectiveValueEntry oldEntry,
EffectiveValueEntry newEntry,
OperationType operationType)
{
_property = property;
_metadata = metadata;
_oldEntry = oldEntry;
_newEntry = newEntry;
_flags = 0;
_operationType = operationType;
IsAValueChange = isAValueChange;
// This is when a mutable default is promoted to a local value. On this operation mutable default
// value acquires a freezable context. However this value promotion operation is triggered
// whenever there has been a sub property change to the mutable default. Eg. Adding a TextEffect
// to a TextEffectCollection instance which is the mutable default. Since we missed the sub property
// change due to this add, we flip the IsASubPropertyChange bit on the following change caused by
// the value promotion to coalesce these operations.
IsASubPropertyChange = (operationType == OperationType.ChangeMutableDefaultValue);
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:25,代码来源:DependencyPropertyChangedEventArgs.cs
示例16: SourcePropertyChanged
internal void SourcePropertyChanged(object sender, DependencyProperty dp)
{
if (dp == this.sourceProperty)
{
this.target.RefreshExpression(this.targetProperty);
}
}
开发者ID:evnik,项目名称:UIFramework,代码行数:7,代码来源:TemplateBindingExpression.cs
示例17: CoerceKeyTip
public static object CoerceKeyTip(ISyncKeyTipAndContent syncElement,
object baseValue,
DependencyProperty contentProperty)
{
DependencyObject element = syncElement as DependencyObject;
Debug.Assert(element != null);
if (syncElement.KeepKeyTipAndContentInSync &&
!syncElement.IsKeyTipSyncSource)
{
syncElement.KeepKeyTipAndContentInSync = false;
if (string.IsNullOrEmpty((string)baseValue))
{
string stringContent = element.GetValue(contentProperty) as string;
if (stringContent != null)
{
int accessIndex = RibbonHelper.FindAccessKeyMarker(stringContent);
if (accessIndex >= 0 && accessIndex < stringContent.Length - 1)
{
syncElement.KeepKeyTipAndContentInSync = true;
return StringInfo.GetNextTextElement(stringContent, accessIndex + 1);
}
}
}
}
return baseValue;
}
开发者ID:amitkr2007,项目名称:groups-dct-sms,代码行数:26,代码来源:RibbonKeyTipAndContentSyncHelper.cs
示例18: ZoomBox
static ZoomBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomBox), new FrameworkPropertyMetadata(typeof(ZoomBox)));
ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(string), typeof(ZoomBox), new FrameworkPropertyMetadata());
ZoomProperty = DependencyProperty.Register("Zoom", typeof(Double), typeof(ZoomBox), new FrameworkPropertyMetadata(1.0, FrameworkPropertyMetadataOptions.None, ZoomPropertyChangedCallback));
}
开发者ID:akappel,项目名称:screentogif,代码行数:7,代码来源:ZoomBox.cs
示例19: CornerRadiusAnimation
static CornerRadiusAnimation()
{
Type typeofProp = typeof(CornerRadius?);
Type typeofThis = typeof(CornerRadiusAnimation);
PropertyChangedCallback propCallback = new PropertyChangedCallback(AnimationFunction_Changed);
ValidateValueCallback validateCallback = new ValidateValueCallback(ValidateFromToOrByValue);
FromProperty = DependencyProperty.Register(
"From",
typeofProp,
typeofThis,
new PropertyMetadata((CornerRadius?)null, propCallback),
validateCallback);
ToProperty = DependencyProperty.Register(
"To",
typeofProp,
typeofThis,
new PropertyMetadata((CornerRadius?)null, propCallback),
validateCallback);
ByProperty = DependencyProperty.Register(
"By",
typeofProp,
typeofThis,
new PropertyMetadata((CornerRadius?)null, propCallback),
validateCallback);
}
开发者ID:grandtiger,项目名称:wpf-shell,代码行数:28,代码来源:CornerRadiusAnimation.cs
示例20: SmoothSetAsync
public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue,
TimeSpan iDuration, CancellationToken iCancellationToken)
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration));
PropertyPath p = new PropertyPath("(0)", dp);
Storyboard.SetTargetProperty(anim, p);
Storyboard sb = new Storyboard();
sb.Children.Add(anim);
EventHandler handler = null;
handler = delegate
{
sb.Completed -= handler;
sb.Remove(@this);
@this.SetValue(dp, targetvalue);
tcs.TrySetResult(null);
};
sb.Completed += handler;
sb.Begin(@this, true);
iCancellationToken.Register(() =>
{
double v = (double)@this.GetValue(dp);
sb.Stop();
sb.Remove(@this);
@this.SetValue(dp, v);
tcs.TrySetCanceled();
});
return tcs.Task;
}
开发者ID:David-Desmaisons,项目名称:MusicCollection,代码行数:31,代码来源:FrameworkElementExtender.cs
注:本文中的System.Windows.DependencyProperty类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论