本文整理汇总了C#中MainWindow.TryFindResource方法的典型用法代码示例。如果您正苦于以下问题:C# MainWindow.TryFindResource方法的具体用法?C# MainWindow.TryFindResource怎么用?C# MainWindow.TryFindResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWindow
的用法示例。
在下文中一共展示了MainWindow.TryFindResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewManager
public ViewManager(MainWindow window)
{
_window = window;
_mainContainer = (Grid)window.FindName("mainGrid");
_imageScrollBar = (ScrollBar)window.FindName("imageScrollBar");
_progressScrollBar = (ScrollBar)window.FindName("progressScrollBar");
_rotateTransform = (RotateTransform)window.FindName("displayRotateTransform");
_imageTranslateTransform = (TranslateTransform)window.FindName("imageTranslateTransform");
_comicImage = (Image)window.FindName("comicImage");
/*
// NOTE: keep this code as an example on how to monitor property changes
// This code is required because WPF Image control does not have a ImageLoaded event.
DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(Image.SourceProperty, typeof(Image));
dpd.AddValueChanged(_comicImage, OnImageChanged);
*/
_imageViewbox = (Viewbox)window.FindName("imageViewbox");
_imageViewbox.SizeChanged += OnImageViewboxSizeChanged;
_pixelMatrix = PresentationSource.FromVisual(_window).CompositionTarget.TransformToDevice;
_portraitStoryboard = (Storyboard)_window.TryFindResource("portraitStoryboard");
_landscapeStoryboard = (Storyboard)_window.TryFindResource("landscapeStoryboard");
_portraitStoryboard.Completed += OnRotationStoryboardCompleted;
_landscapeStoryboard.Completed += OnRotationStoryboardCompleted;
_translateXStoryboard = (Storyboard)_window.TryFindResource("translateXStoryboard");
_translateYStoryboard = (Storyboard)_window.TryFindResource("translateYStoryboard");
_translateXDoubleAnimation = (DoubleAnimation)_translateXStoryboard.Children[0];
_translateYDoubleAnimation = (DoubleAnimation)_translateYStoryboard.Children[0];
// Assumes both X and Y double animation have the same duration
TRANSLATE_DURATION = _translateXDoubleAnimation.Duration;
_numberingContainer = (Border)window.FindName("numberingBorder");
_imageScrollBarAnimation = new DoubleAnimation();
_imageScrollBarAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
_imageScrollBarAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
//TODO: add gesture handling
/*_window.PreviewMouseMove += _window_MouseMove;*/
}