private static void RiseIsPinnedChanged(MiniButton button) { if (button.m_isPinButton) { VisualStateManager.GoToState(button, button.IsPinned ? "Pressed" : "Normal", true); if (button.IsPinned) { button.m_image.Source = new BitmapImage(new Uri(button.PinnedImage, UriKind.Relative)); } else { button.m_image.Source = new BitmapImage(new Uri(button.Image, UriKind.Relative)); } } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); this.m_scrollViewerContent = GetTemplateChild("ScrollViewerContent") as ScrollViewer; this.m_pinnedPlaceHolder = GetTemplateChild("PinnedPlaceHolder") as Grid; this.m_unpinnedPlaceHolder = GetTemplateChild("UnpinnedPlaceHolder") as Grid; this.m_functionPanel = GetTemplateChild("FuncPanel") as Grid; this.m_anchorPlaceHolder = GetTemplateChild("AnchorPlaceHolder") as Grid; if (this.FunctionContent == null) { this.m_functionPanel.Visibility = System.Windows.Visibility.Collapsed; IsPinned = false; } if (this.m_buttonGoTop != null) { this.m_buttonGoTop.Click -= new RoutedEventHandler(m_buttonGoTop_Click); } this.m_buttonGoTop = GetTemplateChild("ButtonGoTop") as Button; if (this.m_buttonGoTop != null) { this.m_buttonGoTop.Click += new RoutedEventHandler(m_buttonGoTop_Click); } if (this.Anchors != null && this.Anchors.Count > 0) { if (this.m_anchorList != null) { this.m_anchorList.MouseLeftButtonUp -= new MouseButtonEventHandler(m_anchorList_MouseLeftButtonUp); } this.m_anchorList = GetTemplateChild("AnchorList") as ItemsControl; this.m_anchorList.MouseLeftButtonUp += new MouseButtonEventHandler(m_anchorList_MouseLeftButtonUp); this.m_anchorList.ItemsSource = this.Anchors; } else { if (this.m_anchorPlaceHolder != null) { this.m_anchorPlaceHolder.Visibility = Visibility.Collapsed; } } if (this.m_buttonPin != null) { this.m_buttonPin.Click -= new RoutedEventHandler(m_buttonPin_Click); } this.m_buttonPin = GetTemplateChild("ButtonPin") as MiniButton; if (this.m_buttonPin != null) { this.m_buttonPin.IsPinned = this.IsPinned; this.m_buttonPin.Click += new RoutedEventHandler(m_buttonPin_Click); } if (this.m_pinnedPlaceHolder != null && this.m_unpinnedPlaceHolder != null) { this.OnIsPinnedChanged(); } if (this.m_scrollViewerContent != null) { this.m_scrollViewerContent.LayoutUpdated += new EventHandler(m_scrollViewerContent_LayoutUpdated); } if (this.TraceFunctionEvent && this.FunctionContent != null) { RegisterTraceEvent((DependencyObject)this.FunctionContent); } }