本文整理汇总了C#中System.Windows.DependencyPropertyChangedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DependencyPropertyChangedEventArgs类的具体用法?C# DependencyPropertyChangedEventArgs怎么用?C# DependencyPropertyChangedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyPropertyChangedEventArgs类属于System.Windows命名空间,在下文中一共展示了DependencyPropertyChangedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSizeChanged
private static void OnSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var image = d as Image;
if (image == null)
{
throw new ArgumentException(
"You must set the Command attached property on an element that derives from Image.");
}
var oldCommand = (bool)e.OldValue;
if (oldCommand)
{
image.Loaded -= OnLoaded;
image.SizeChanged -= OnSizeChanged;
}
var newCommand = (bool)e.NewValue;
if (newCommand)
{
image.Loaded += OnLoaded;
image.SizeChanged += OnSizeChanged;
}
image.CropImageBorders();
}
示例2: OnModelChanged
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Model property.
/// </summary>
protected virtual void OnModelChanged(DependencyPropertyChangedEventArgs e)
{
if (Model != null)
SetLayoutItem(Model.Root.Manager.GetLayoutItemFromModel(Model));
else
SetLayoutItem(null);
}
示例3: OnScrollGroupChanged
private static void OnScrollGroupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
var scrollViewer = d as ScrollViewer;
if (scrollViewer != null) {
if (!string.IsNullOrEmpty((string)e.OldValue)) {
// Remove scrollviewer
if (scrollViewers.ContainsKey(scrollViewer)) {
scrollViewer.ScrollChanged -=
new ScrollChangedEventHandler(ScrollViewer_ScrollChanged);
scrollViewers.Remove(scrollViewer);
}
}
if (!string.IsNullOrEmpty((string)e.NewValue)) {
if (verticalScrollOffsets.Keys.Contains((string)e.NewValue)) {
scrollViewer.ScrollToVerticalOffset(verticalScrollOffsets[(string)e.NewValue]);
} else {
verticalScrollOffsets.Add((string)e.NewValue, scrollViewer.VerticalOffset);
}
// Add scrollviewer
scrollViewers.Add(scrollViewer, (string)e.NewValue);
scrollViewer.ScrollChanged += new ScrollChangedEventHandler(ScrollViewer_ScrollChanged);
}
}
}
示例4: OnAttachChanged
public static void OnAttachChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var passwordBox = sender as PasswordBox;
if (passwordBox == null) return;
if ((bool)e.OldValue) passwordBox.PasswordChanged -= PasswordChanged;
if ((bool)e.NewValue) passwordBox.PasswordChanged += PasswordChanged;
}
示例5: OnScrollOnTextChanged
static void OnScrollOnTextChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
var textBox = dependencyObject as TextBox;
if (textBox == null)
{
return;
}
bool oldValue = (bool)e.OldValue, newValue = (bool)e.NewValue;
if (newValue == oldValue)
{
return;
}
if (newValue)
{
textBox.Loaded += TextBoxLoaded;
textBox.Unloaded += TextBoxUnloaded;
}
else
{
textBox.Loaded -= TextBoxLoaded;
textBox.Unloaded -= TextBoxUnloaded;
if (_associations.ContainsKey(textBox))
{
_associations[textBox].Dispose();
}
}
}
示例6: OnSourceChanged
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Source property.
/// </summary>
protected virtual void OnSourceChanged(DependencyPropertyChangedEventArgs e)
{
ClearAnimation();
var source = e.NewValue as BitmapImage;
if(source == null) {
Uri uri = e.NewValue as Uri;
if(uri == null) {
var bitmapframe = e.NewValue as BitmapFrame;
if(bitmapframe == null) {
var imgsrc = e.NewValue as ImageSource;
base.Source = imgsrc;
return;
}
uri = new Uri(e.NewValue.ToString());
}
source = new BitmapImage();
source.BeginInit();
source.UriSource = uri;
source.CacheOption = BitmapCacheOption.OnLoad;
source.EndInit();
}
if(!IsAnimatedGifImage(source)) {
base.Source = source;
return;
}
PrepareAnimation(source);
}
示例7: Generate
/// <summary>
/// Sets the coordinates of all the individual lines in the visual.
/// </summary>
/// <param name="args">
/// The <c>DependencyPropertyChangedEventArgs</c> object associated
/// with the property-changed event that resulted in this method
/// being called.
/// </param>
/// <param name="lines">
/// The <c>Point3DCollection</c> to be filled.
/// </param>
/// <remarks>
/// <para>
/// Classes that derive from <c>WireBase</c> override this
/// method to fill the <c>lines</c> collection.
/// It is custmary for implementations of this method to clear
/// the <c>lines</c> collection first before filling it.
/// Each pair of successive members of the <c>lines</c>
/// collection indicate one straight line.
/// </para>
/// <para>
/// The <c>WireLine</c> class implements this method by
/// clearing the <c>lines</c> collection and then adding
/// <c>Point1</c> and <c>Point2</c> to the collection.
/// </para>
/// </remarks>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
lines.Clear();
lines.Add(Point1);
lines.Add(Point2);
}
示例8: OnDeckChanged
private static void OnDeckChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var viewer = d as DeckCardsViewer;
var newdeck = e.NewValue as MetaDeck ?? new MetaDeck(){IsCorrupt = true};
var g = GameManager.Get().GetById(newdeck.GameId);
viewer.deck = newdeck.IsCorrupt ?
null
: g == null ?
null
: newdeck;
viewer._view = viewer.deck == null ?
new ListCollectionView(new List<MetaMultiCard>())
: new ListCollectionView(viewer.deck.Sections.SelectMany(x => x.Cards).ToList());
viewer.OnPropertyChanged("Deck");
viewer.OnPropertyChanged("SelectedCard");
Task.Factory.StartNew(
() =>
{
Thread.Sleep(0);
viewer.Dispatcher.BeginInvoke(new Action(
() =>
{
viewer.FilterChanged(viewer._filter);
}));
});
}
示例9: OnIsPivotAnimatedChanged
private static void OnIsPivotAnimatedChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
{
ItemsControl list = d as ItemsControl;
list.Loaded += (s2, e2) =>
{
// locate the pivot control that this list is within
Pivot pivot = list.Ancestors<Pivot>().Single() as Pivot;
// and its index within the pivot
int pivotIndex = pivot.Items.IndexOf(list.Ancestors<PivotItem>().Single());
bool selectionChanged = false;
pivot.SelectionChanged += (s3, e3) =>
{
selectionChanged = true;
};
// handle manipulation events which occur when the user
// moves between pivot items
pivot.ManipulationCompleted += (s, e) =>
{
if (!selectionChanged)
return;
selectionChanged = false;
if (pivotIndex != pivot.SelectedIndex)
return;
// determine which direction this tab will be scrolling in from
bool fromRight = e.TotalManipulation.Translation.X <= 0;
// locate the stack panel that hosts the items
VirtualizingStackPanel vsp = list.Descendants<VirtualizingStackPanel>().First() as VirtualizingStackPanel;
// iterate over each of the items in view
int firstVisibleItem = (int)vsp.VerticalOffset;
int visibleItemCount = (int)vsp.ViewportHeight;
for (int index = firstVisibleItem; index <= firstVisibleItem + visibleItemCount; index++)
{
// find all the item that have the AnimationLevel attached property set
var lbi = list.ItemContainerGenerator.ContainerFromIndex(index);
if (lbi == null)
continue;
vsp.Dispatcher.BeginInvoke(() =>
{
var animationTargets = lbi.Descendants().Where(p => ListAnimation.GetAnimationLevel(p) > -1);
foreach (FrameworkElement target in animationTargets)
{
// trigger the required animation
GetAnimation(target, fromRight).Begin();
}
});
};
};
};
}
示例10: OnGroupNameChanged
private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//Add an entry to the group name collection
var menuItem = d as MenuItem;
if (menuItem != null)
{
String newGroupName = e.NewValue.ToString();
String oldGroupName = e.OldValue.ToString();
if (String.IsNullOrEmpty(newGroupName))
{
//Removing the toggle button from grouping
RemoveCheckboxFromGrouping(menuItem);
}
else
{
//Switching to a new group
if (newGroupName != oldGroupName)
{
if (!String.IsNullOrEmpty(oldGroupName))
{
//Remove the old group mapping
RemoveCheckboxFromGrouping(menuItem);
}
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
menuItem.Checked += MenuItemChecked;
}
}
}
}
示例11: KPage_VisibleChanged
/// <summary>
/// Wird bei Seitenwechsel aufgerufen
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void KPage_VisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (!((KPage)sender).IsVisible) // Beim Verlassen der Seite nichts machen
return;
refreshDataGrid();
}
示例12: AnnotationsGroupChanged
private static void AnnotationsGroupChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
{
RadCartesianChart chart = target as RadCartesianChart;
if (chart == null)
{
return;
}
string group = (string)args.NewValue;
if (group != null && !attachedCharts.Contains(chart))
{
attachedCharts.Add(chart);
chart.MouseMove += Chart_MouseMove;
chart.MouseLeave += Chart_MouseLeave;
}
else if (group == null)
{
chart.MouseMove -= Chart_MouseMove;
attachedCharts.Remove(chart);
chart.MouseLeave -= Chart_MouseLeave;
if (lastMouseOveredChart == chart)
{
lastMouseOveredChart = null;
}
}
}
示例13: OnTransformChanged
private static void OnTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.SetValue(UIElement.RenderTransformProperty, e.NewValue);
if (TrackableRenderTransform.TransformChanged == null)
return;
TrackableRenderTransform.TransformChanged(d, e);
}
示例14: TextboxInlinesPropertyChanged
private static void TextboxInlinesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var textBlock = d as TextBlock;
if (textBlock == null)
return;
SetTextBlockInlines(textBlock, e.NewValue as IEnumerable<Inline>);
}
示例15: OnValidSpinDirectionPropertyChanged
/// <summary>
/// ValidSpinDirectionProperty property changed handler.
/// </summary>
/// <param name="d">ButtonSpinner that changed its ValidSpinDirection.</param>
/// <param name="e">Event arguments.</param>
private static void OnValidSpinDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Spinner source = (Spinner)d;
ValidSpinDirections oldvalue = (ValidSpinDirections)e.OldValue;
ValidSpinDirections newvalue = (ValidSpinDirections)e.NewValue;
source.OnValidSpinDirectionChanged(oldvalue, newvalue);
}