本文整理匯總了C#中Windows.UI.Xaml.DependencyProperty類的典型用法代碼示例。如果您正苦於以下問題:C# DependencyProperty類的具體用法?C# DependencyProperty怎麽用?C# DependencyProperty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DependencyProperty類屬於Windows.UI.Xaml命名空間,在下文中一共展示了DependencyProperty類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: StarRateControl
public StarRateControl()
{
this.InitializeComponent();
valueProperty = DependencyProperty.Register("Value", typeof(int), typeof(StarRateControl), new PropertyMetadata(3));
}
示例2: SetValueDp
void SetValueDp(DependencyProperty property, object value, [System.Runtime.CompilerServices.CallerMemberName] String p = null)
{
SetValue(property, value);
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(p));
}
示例3: FrameworkElementAttachedProperties
static FrameworkElementAttachedProperties()
{
ObserveProperty = DependencyProperty.RegisterAttached("Observe", typeof(bool), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, new PropertyChangedCallback(OnObserveChanged)));
ObservedWidthProperty = DependencyProperty.RegisterAttached("ObservedWidth", typeof(double), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, null));
ObservedHeightProperty = DependencyProperty.RegisterAttached("ObservedHeight", typeof(double), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, null));
LoadedCommandProperty = DependencyProperty.RegisterAttached("LoadedCommand", typeof(ICommand), typeof(FrameworkElementAttachedProperties), new PropertyMetadata(null, OnLoadedCommandChanged));
}
示例4: OnHeaderPresenterContentChanged
private void OnHeaderPresenterContentChanged(DependencyObject sender, DependencyProperty dp)
{
if (headerPresenter.Content != Header)
{
headerPresenter.Content = Header;
}
}
示例5: SuspendHandler
/// <summary>
/// Inherited code: Requires comment.
/// </summary>
/// <param name="obj">Inherited code: Requires comment 1.</param>
/// <param name="dependencyProperty">Inherited code: Requires comment 2.</param>
/// <param name="suspend">Inherited code: Requires comment 3.</param>
private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
{
if (_suspendedHandlers.ContainsKey(obj))
{
Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];
if (suspend)
{
Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "Suspensions should not contain the property!");
// true = dummy value
suspensions[dependencyProperty] = true;
}
else
{
Debug.Assert(suspensions.ContainsKey(dependencyProperty), "Suspensions should contain the property!");
suspensions.Remove(dependencyProperty);
if (suspensions.Count == 0)
{
_suspendedHandlers.Remove(obj);
}
}
}
else
{
Debug.Assert(suspend, "suspend should be true!");
_suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
_suspendedHandlers[obj][dependencyProperty] = true;
}
}
示例6: SettingsEditor
static SettingsEditor()
{
YScaleWidthProperty = DependencyProperty.Register("YScaleWidth", typeof(int), typeof(SettingsEditor), new PropertyMetadata(60));
XScaleHeightProperty = DependencyProperty.Register("XScaleHeight", typeof(int), typeof(SettingsEditor), new PropertyMetadata(15));
BorderThickness1Property = DependencyProperty.Register("BorderThickness1", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
BorderProperty = DependencyProperty.Register("Border", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Black"));
YScaleDockProperty = DependencyProperty.Register("YScaleDock", typeof(YScaleDock), typeof(SettingsEditor), new PropertyMetadata(YScaleDock.Right));
ControlBackgroundProperty = DependencyProperty.Register("ControlBackground", typeof(string), typeof(SettingsEditor), new PropertyMetadata("White"));
XScaleDockProperty = DependencyProperty.Register("XScaleDock", typeof(XScaleDock), typeof(SettingsEditor), new PropertyMetadata(XScaleDock.Bottom));
CoordinateTypeProperty = DependencyProperty.Register("CoordinateType", typeof(CoordinateType), typeof(SettingsEditor), new PropertyMetadata(CoordinateType.Linear));
CursorLinesProperty = DependencyProperty.Register("CursorLines", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Gray"));
CursorLinesThicknessProperty = DependencyProperty.Register("CursorLinesThickness", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
CursorLinesDashesProperty = DependencyProperty.Register("CursorLinesDashes", typeof(string), typeof(SettingsEditor), new PropertyMetadata(null));
ScaleLineColorProperty = DependencyProperty.Register("ScaleLineColor", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Gray"));
ScaleLineThicknessProperty = DependencyProperty.Register("ScaleLineThickness", typeof(int), typeof(SettingsEditor), new PropertyMetadata(1));
ScaleLineDashesProperty = DependencyProperty.Register("ScaleLineDashes", typeof(string), typeof(SettingsEditor), new PropertyMetadata(null));
FontFamilyProperty = DependencyProperty.Register("FontFamily", typeof(string), typeof(SettingsEditor), new PropertyMetadata("Arial"));
FontSizeProperty = DependencyProperty.Register("FontSize", typeof(int), typeof(SettingsEditor), new PropertyMetadata(10));
widthArrayProperty = DependencyProperty.Register("widthArray", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
brushesProperty = DependencyProperty.Register("brushes", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
yScaleDocksProperty = DependencyProperty.Register("yScaleDocks", typeof(YScaleDock[]), typeof(SettingsEditor), new PropertyMetadata(null));
xScaleDocksProperty = DependencyProperty.Register("xScaleDocks", typeof(XScaleDock[]), typeof(SettingsEditor), new PropertyMetadata(null));
bgBrushesProperty = DependencyProperty.Register("bgBrushes", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
dockWidthArrayProperty = DependencyProperty.Register("dockWidthArray", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
coordinateTypesProperty = DependencyProperty.Register("coordinateTypes", typeof(CoordinateType[]), typeof(SettingsEditor), new PropertyMetadata(null));
dashArrayProperty = DependencyProperty.Register("dashArray", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
fontNamesProperty = DependencyProperty.Register("fontNames", typeof(string[]), typeof(SettingsEditor), new PropertyMetadata(null));
fontSizesProperty = DependencyProperty.Register("fontSizes", typeof(int[]), typeof(SettingsEditor), new PropertyMetadata(null));
}
示例7: BeginAnimation
/// <summary>
/// Starts animating a dependency property of a framework element to a
/// target value.
/// </summary>
/// <param name="target">The element to animate.</param>
/// <param name="animatingDependencyProperty">The dependency property to
/// animate.</param>
/// <param name="propertyPath">The path of the dependency property to
/// animate.</param>
/// <param name="targetValue">The value to animate the dependency
/// property to.</param>
/// <param name="timeSpan">The duration of the animation.</param>
/// <param name="easingFunction">The easing function to uses to
/// transition the data points.</param>
public static void BeginAnimation(
this FrameworkElement target,
DependencyProperty animatingDependencyProperty,
string propertyPath,
object targetValue,
TimeSpan timeSpan,
EasingFunctionBase easingFunction)
{
Storyboard storyBoard = target.Resources[GetStoryboardKey(propertyPath)] as Storyboard;
if (storyBoard != null)
{
// Save current value
object currentValue = target.GetValue(animatingDependencyProperty);
storyBoard.Stop();
// RestoreAsync that value so it doesn't snap back to its starting value
target.SetValue(animatingDependencyProperty, currentValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
}
storyBoard = CreateStoryboard(target, animatingDependencyProperty, propertyPath, ref targetValue, timeSpan, easingFunction);
storyBoard.Completed +=
(source, args) =>
{
storyBoard.Stop();
target.SetValue(animatingDependencyProperty, targetValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
};
target.Resources.Add(GetStoryboardKey(propertyPath), storyBoard);
storyBoard.Begin();
}
示例8: OnItemsSourceChanged
private void OnItemsSourceChanged(DependencyObject sender, DependencyProperty dp)
{
if (this.ItemsSource != null && ItemsSource is IGroupCollection)
{
groupCollection = (ItemsSource as IGroupCollection);
}
if (groupHeadersGrid != null)
{
groupHeadersGrid.Children.Clear();
}
groupDic.Clear();
if (currentTopGroupHeader != null)
{
currentTopGroupHeader.DataContext = null;
currentTopGroupHeader.Visibility = Visibility.Collapsed;
if (groupHeadersGrid != null)
{
groupHeadersGrid.Children.Add(currentTopGroupHeader);
}
}
else
{
if (groupHeadersGrid != null)
{
currentTopGroupHeader = CreateGroupHeader(null);
currentTopGroupHeader.Visibility = Visibility.Collapsed;
groupHeadersGrid.Children.Add(currentTopGroupHeader);
}
}
}
示例9: VisibilityChangedCallback
private void VisibilityChangedCallback(DependencyObject sender, DependencyProperty dp)
{
if (Visibility == Visibility.Visible)
{
EntryBox.Text = FilterSting;
}
}
示例10: TextBlockFontSize
static TextBlockFontSize()
{
FontSizeProperty = DependencyProperty.Register("FontSize",
typeof(int),
typeof(TextBlockFontSize),
new PropertyMetadata(TextBlock.FontSizeProperty, null));
}
示例11: RefreshBinding
private static void RefreshBinding(DependencyObject target, DependencyProperty property)
{
BindingExpression binding = target.ReadLocalValue(property) as BindingExpression;
if (binding != null && binding.ParentBinding != null)
{
BindingOperations.SetBinding(target, property, binding.ParentBinding);
}
}
示例12: SetBinding
/// <summary>
/// Sets a binding from code
/// </summary>
/// <param name="element"></param>
/// <param name="property"></param>
/// <param name="source"></param>
/// <param name="path"></param>
/// <param name="converter"></param>
public static void SetBinding(FrameworkElement element, DependencyProperty property, object source, string path, IValueConverter converter = null)
{
Binding binding = new Binding();
binding.Source = source;
binding.Path = new PropertyPath(path);
binding.Converter = converter;
element.SetBinding(property, binding);
}
示例13: SetValueDp
private void SetValueDp(DependencyProperty property, object value, [CallerMemberName] string propertyName = null)
{
SetValue(property, value);
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
示例14: OnMinWindowWidthPropertyChanged
private void OnMinWindowWidthPropertyChanged(DependencyObject sender, DependencyProperty dp)
{
var window = CoreApplication.GetCurrentView()?.CoreWindow;
if (window != null)
{
IsActive = window.Bounds.Width >= MinWindowWidth;
}
}
示例15: HeaderChanged
void HeaderChanged(DependencyObject sender, DependencyProperty prop)
{
string header = (string)sender.GetValue(prop);
//Double check to make sure that we don't needlessly realize the header presenter
if (!string.IsNullOrEmpty(Header) && _header == null)
{
_header = (ContentPresenter)GetTemplateChild("HeaderPresenter"); //This will realize the element
}
}