本文整理匯總了C#中Windows.UI.Xaml.DependencyObject類的典型用法代碼示例。如果您正苦於以下問題:C# DependencyObject類的具體用法?C# DependencyObject怎麽用?C# DependencyObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DependencyObject類屬於Windows.UI.Xaml命名空間,在下文中一共展示了DependencyObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnCacheUriChanged
private static async void OnCacheUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//Uri oldCacheUri = (Uri)e.OldValue;
Uri newCacheUri = (Uri)d.GetValue(CacheUriProperty);
var image = (Image)d;
if (newCacheUri != null)
{
try
{
//Get image from cache (download and set in cache if needed)
var cacheUri = await WebDataCache.GetLocalUriAsync(newCacheUri);
//Set cache uri as source for the image
image.Source = new BitmapImage(cacheUri);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
//Revert to using passed URI
image.Source = new BitmapImage(newCacheUri);
}
}
else
image.Source = null;
}
示例2: SetDismissParentFlyout
public static void SetDismissParentFlyout(DependencyObject obj, bool value)
{
if (obj != null)
{
obj.SetValue(DismissParentFlyoutProperty, value);
}
}
示例3: VisibilityChangedCallback
private void VisibilityChangedCallback(DependencyObject sender, DependencyProperty dp)
{
if (Visibility == Visibility.Visible)
{
EntryBox.Text = FilterSting;
}
}
示例4: PositionChanged
static void PositionChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args)
{
var p = ((FrameworkElement)dp)?.Parent;
if (p == null)
return;
((UIElement)p)?.InvalidateArrange();
}
示例5: OnCommandPropertyChanged
private static void OnCommandPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var control = d as ListViewBase;
if (control != null)
control.ItemClick += OnItemClick;
}
示例6: Attach
public void Attach(DependencyObject associatedObject)
{
AssociatedObject = associatedObject;
// process start
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
element.Visibility = Visibility.Visible;
}
else
{
_dispatcher = Common.DispatcherWrapper.Current();
// throttled calculate event
var observable = Observable.FromEventPattern(this, nameof(DoCalculate));
var throttled = observable.Throttle(TimeSpan.FromMilliseconds(1000));
throttled.Subscribe(x => Calculate());
// handle click
element.Click += new Common.WeakReference<NavButtonBehavior, object, RoutedEventArgs>(this)
{
EventAction = (i, s, e) => Element_Click(s, e),
DetachAction = (i, w) => element.Click -= w.Handler,
}.Handler;
Calculate();
}
}
示例7: PrepareContainerForItemOverride
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
base.PrepareContainerForItemOverride(element, item);
var listViewItem = element as ListViewItem;
if (listViewItem != null)
{
var index = IndexFromContainer(element);
var isOdd = (index + 1)%2 == 1;
// support for adjusting to groups (each group should be threated individually)
var collectionViewSource = Tag as CollectionViewSource;
var groups = collectionViewSource?.Source as IEnumerable<AlphaKeyGroup>;
if (groups != null)
{
var o = Items?[index];
if (o != null)
{
var currentGroup = groups.FirstOrDefault(p => p.Contains(o));
index = currentGroup.IndexOf(o);
isOdd = (index + 1)%2 == 1;
}
}
listViewItem.Background = isOdd
? OddRowBackground ?? new SolidColorBrush((Color) App.Current.Resources["SystemChromeLowColor"])
: EvenRowBackground;
}
}
示例8: Attach
public void Attach( DependencyObject associatedObject )
{
AssociatedObject = associatedObject;
var associatedControl = (Control) associatedObject;
associatedControl.Loaded += ( _, __ ) => associatedControl.Focus( FocusState.Pointer );
}
示例9: OnPathChanged
private static void OnPathChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args )
{
var icon = (Icon) obj;
var data = (string) args.NewValue;
if ( data == null )
{
return;
}
// Copy it since sharing it isn't permitted
var path = (Path) XamlReader.Load( "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Data=\"" + data + "\" />" );
path.Stretch = Stretch.Uniform;
path.HorizontalAlignment = HorizontalAlignment.Center;
path.VerticalAlignment = VerticalAlignment.Center;
path.SetBinding( Path.FillProperty, new Binding { Source = icon, Path = new PropertyPath( "Foreground" ) } );
path.SetBinding( Path.MarginProperty, new Binding { Source = icon, Path = new PropertyPath( "Padding" ) } );
var container = new Border
{
Child = path
};
container.SetBinding( Border.WidthProperty, new Binding { Source = icon, Path = new PropertyPath( "IconWidth" ) } );
container.SetBinding( Border.HeightProperty, new Binding { Source = icon, Path = new PropertyPath( "IconHeight" ) } );
container.SetBinding( Border.BackgroundProperty, new Binding { Source = icon, Path = new PropertyPath( "Background" ) } );
icon.HorizontalAlignment = HorizontalAlignment.Center;
icon.VerticalAlignment = VerticalAlignment.Center;
icon.Content = new Viewbox
{
Child = container
};
}
示例10: OnMessageChanged
private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var notifybar = d as NotificationBar;
var message = e.NewValue as string;
if (message == string.Empty) return;
notifybar?.ShowMessage(message);
}
示例11: OnCommandPropertyChanged
private static void OnCommandPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var control = d as FrameworkElement;
if (control != null)
control.Tapped += OnTapped;
}
示例12: ApplyStyles
public override void ApplyStyles(DocumentStyle style, DependencyObject ctrl, HtmlFragment fragment)
{
var caption = ctrl as Paragraph;
caption.TextAlignment = Parse(style.Img.HorizontalAlignment);
ApplyParagraphStyles(caption, style.FigCaption);
}
示例13: OnMaskChanged
private static void OnMaskChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var target = (TextBoxMaskBehavior)sender;
var oldMask = (TextMask)e.OldValue;
var newMask = (TextMask)e.NewValue;
target.OnMaskChanged(oldMask, newMask);
}
示例14: PrepareContainerForItemOverride
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
{
ItemsControlHelper.PrepareContainerForItemOverride(element, ItemContainerStyle);
PreparePrepareHeaderedItemsControlContainerForItemOverride(element, item, this, ItemContainerStyle);
base.PrepareContainerForItemOverride(element, item);
}
示例15: OnEndAngleChanged
private static void OnEndAngleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
var target = (PieSlice)sender;
var oldEndAngle = (double)e.OldValue;
var newEndAngle = (double)e.NewValue;
target.OnEndAngleChanged(oldEndAngle, newEndAngle);
}