Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Controls / Expander.cs / 1 / Expander.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Automation; using System.Windows.Automation.Peers; using System.Windows.Controls; using System.ComponentModel; using MS.Internal.KnownBoxes; namespace System.Windows.Controls { ////// Specifies the expanding direction of a expansion. /// public enum ExpandDirection { ////// Expander will expand to the down direction. /// Down = 0, ////// Expander will expand to the up direction. /// Up = 1, ////// Expander will expand to the left direction. /// Left = 2, ////// Expander will expand to the right direction. /// Right = 3, } ////// An Expander control allows a user to view a header and expand that /// header to see further details of the content, or to collapse the section /// up to the header to save space. /// [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] // cannot be read & localized as string public class Expander : HeaderedContentControl { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors static Expander() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Expander), new FrameworkPropertyMetadata(typeof(Expander))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(Expander)); IsTabStopProperty.OverrideMetadata(typeof(Expander), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); } #endregion //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// ExpandDirection specifies to which direction the content will expand /// [Bindable(true), Category("Behavior")] public ExpandDirection ExpandDirection { get { return (ExpandDirection) GetValue(ExpandDirectionProperty); } set { SetValue(ExpandDirectionProperty, value); } } ////// The DependencyProperty for the ExpandDirection property. /// Default Value: ExpandDirection.Down /// public static readonly DependencyProperty ExpandDirectionProperty = DependencyProperty.Register( "ExpandDirection", typeof(ExpandDirection), typeof(Expander), new FrameworkPropertyMetadata( ExpandDirection.Down /* default value */, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault), new ValidateValueCallback(IsValidExpandDirection)); private static bool IsValidExpandDirection(object o) { ExpandDirection value = (ExpandDirection)o; return (value == ExpandDirection.Down || value == ExpandDirection.Left || value == ExpandDirection.Right || value == ExpandDirection.Up); } ////// The DependencyProperty for the IsExpanded property. /// Default Value: false /// public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( "IsExpanded", typeof(bool), typeof(Expander), new FrameworkPropertyMetadata( BooleanBoxes.FalseBox /* default value */, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal, new PropertyChangedCallback(OnIsExpandedChanged))); private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Expander ep = (Expander) d; bool newValue = (bool) e.NewValue; // Fire accessibility event ExpanderAutomationPeer peer = UIElementAutomationPeer.FromElement(ep) as ExpanderAutomationPeer; if(peer != null) { peer.RaiseExpandCollapseAutomationEvent(!newValue, newValue); } if (newValue) { ep.OnExpanded(); } else { ep.OnCollapsed(); } } ////// IsExpanded indicates whether the expander is currently expanded. /// [Bindable(true), Category("Appearance")] public bool IsExpanded { get { return (bool) GetValue(IsExpandedProperty); } set { SetValue(IsExpandedProperty, BooleanBoxes.Box(value)); } } ////// Expanded event. /// public static readonly RoutedEvent ExpandedEvent = EventManager.RegisterRoutedEvent("Expanded", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Expander) ); ////// Expanded event. It is fired when IsExpanded changed from false to true. /// public event RoutedEventHandler Expanded { add { AddHandler(ExpandedEvent, value); } remove { RemoveHandler(ExpandedEvent, value); } } ////// Collapsed event. /// public static readonly RoutedEvent CollapsedEvent = EventManager.RegisterRoutedEvent("Collapsed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Expander) ); ////// Collapsed event. It is fired when IsExpanded changed from true to false. /// public event RoutedEventHandler Collapsed { add { AddHandler(CollapsedEvent, value); } remove { RemoveHandler(CollapsedEvent, value); } } #endregion //-------------------------------------------------------------------- // // Protected Methods // //-------------------------------------------------------------------- #region Protected Methods ////// A virtual function that is called when the IsExpanded property is changed to true. /// Default behavior is to raise an ExpandedEvent. /// protected virtual void OnExpanded() { RoutedEventArgs args = new RoutedEventArgs(); args.RoutedEvent =(Expander.ExpandedEvent); args.Source=this; RaiseEvent(args); } ////// A virtual function that is called when the IsExpanded property is changed to false. /// Default behavior is to raise a CollapsedEvent. /// protected virtual void OnCollapsed() { RaiseEvent(new RoutedEventArgs(Expander.CollapsedEvent, this)); } #endregion #region Accessibility ////// Creates AutomationPeer ( protected override AutomationPeer OnCreateAutomationPeer() { return new ExpanderAutomationPeer(this); } #endregion //------------------------------------------------------------------- // // Private Fields // //-------------------------------------------------------------------- #region Private Fields #endregion #region DTypeThemeStyleKey // Returns the DependencyObjectType for the registered ThemeStyleKey's default // value. Controls will override this method to return approriate types. internal override DependencyObjectType DTypeThemeStyleKey { get { return _dType; } } private static DependencyObjectType _dType; #endregion DTypeThemeStyleKey } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Automation; using System.Windows.Automation.Peers; using System.Windows.Controls; using System.ComponentModel; using MS.Internal.KnownBoxes; namespace System.Windows.Controls { ///) /// /// Specifies the expanding direction of a expansion. /// public enum ExpandDirection { ////// Expander will expand to the down direction. /// Down = 0, ////// Expander will expand to the up direction. /// Up = 1, ////// Expander will expand to the left direction. /// Left = 2, ////// Expander will expand to the right direction. /// Right = 3, } ////// An Expander control allows a user to view a header and expand that /// header to see further details of the content, or to collapse the section /// up to the header to save space. /// [Localizability(LocalizationCategory.None, Readability = Readability.Unreadable)] // cannot be read & localized as string public class Expander : HeaderedContentControl { //------------------------------------------------------------------- // // Constructors // //------------------------------------------------------------------- #region Constructors static Expander() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Expander), new FrameworkPropertyMetadata(typeof(Expander))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(Expander)); IsTabStopProperty.OverrideMetadata(typeof(Expander), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); } #endregion //-------------------------------------------------------------------- // // Public Properties // //------------------------------------------------------------------- #region Public Properties ////// ExpandDirection specifies to which direction the content will expand /// [Bindable(true), Category("Behavior")] public ExpandDirection ExpandDirection { get { return (ExpandDirection) GetValue(ExpandDirectionProperty); } set { SetValue(ExpandDirectionProperty, value); } } ////// The DependencyProperty for the ExpandDirection property. /// Default Value: ExpandDirection.Down /// public static readonly DependencyProperty ExpandDirectionProperty = DependencyProperty.Register( "ExpandDirection", typeof(ExpandDirection), typeof(Expander), new FrameworkPropertyMetadata( ExpandDirection.Down /* default value */, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault), new ValidateValueCallback(IsValidExpandDirection)); private static bool IsValidExpandDirection(object o) { ExpandDirection value = (ExpandDirection)o; return (value == ExpandDirection.Down || value == ExpandDirection.Left || value == ExpandDirection.Right || value == ExpandDirection.Up); } ////// The DependencyProperty for the IsExpanded property. /// Default Value: false /// public static readonly DependencyProperty IsExpandedProperty = DependencyProperty.Register( "IsExpanded", typeof(bool), typeof(Expander), new FrameworkPropertyMetadata( BooleanBoxes.FalseBox /* default value */, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal, new PropertyChangedCallback(OnIsExpandedChanged))); private static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Expander ep = (Expander) d; bool newValue = (bool) e.NewValue; // Fire accessibility event ExpanderAutomationPeer peer = UIElementAutomationPeer.FromElement(ep) as ExpanderAutomationPeer; if(peer != null) { peer.RaiseExpandCollapseAutomationEvent(!newValue, newValue); } if (newValue) { ep.OnExpanded(); } else { ep.OnCollapsed(); } } ////// IsExpanded indicates whether the expander is currently expanded. /// [Bindable(true), Category("Appearance")] public bool IsExpanded { get { return (bool) GetValue(IsExpandedProperty); } set { SetValue(IsExpandedProperty, BooleanBoxes.Box(value)); } } ////// Expanded event. /// public static readonly RoutedEvent ExpandedEvent = EventManager.RegisterRoutedEvent("Expanded", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Expander) ); ////// Expanded event. It is fired when IsExpanded changed from false to true. /// public event RoutedEventHandler Expanded { add { AddHandler(ExpandedEvent, value); } remove { RemoveHandler(ExpandedEvent, value); } } ////// Collapsed event. /// public static readonly RoutedEvent CollapsedEvent = EventManager.RegisterRoutedEvent("Collapsed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Expander) ); ////// Collapsed event. It is fired when IsExpanded changed from true to false. /// public event RoutedEventHandler Collapsed { add { AddHandler(CollapsedEvent, value); } remove { RemoveHandler(CollapsedEvent, value); } } #endregion //-------------------------------------------------------------------- // // Protected Methods // //-------------------------------------------------------------------- #region Protected Methods ////// A virtual function that is called when the IsExpanded property is changed to true. /// Default behavior is to raise an ExpandedEvent. /// protected virtual void OnExpanded() { RoutedEventArgs args = new RoutedEventArgs(); args.RoutedEvent =(Expander.ExpandedEvent); args.Source=this; RaiseEvent(args); } ////// A virtual function that is called when the IsExpanded property is changed to false. /// Default behavior is to raise a CollapsedEvent. /// protected virtual void OnCollapsed() { RaiseEvent(new RoutedEventArgs(Expander.CollapsedEvent, this)); } #endregion #region Accessibility ////// Creates AutomationPeer ( protected override AutomationPeer OnCreateAutomationPeer() { return new ExpanderAutomationPeer(this); } #endregion //------------------------------------------------------------------- // // Private Fields // //-------------------------------------------------------------------- #region Private Fields #endregion #region DTypeThemeStyleKey // Returns the DependencyObjectType for the registered ThemeStyleKey's default // value. Controls will override this method to return approriate types. internal override DependencyObjectType DTypeThemeStyleKey { get { return _dType; } } private static DependencyObjectType _dType; #endregion DTypeThemeStyleKey } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.) ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WaitForChangedResult.cs
- OleDbParameterCollection.cs
- DependencyObjectProvider.cs
- SynchronizingStream.cs
- DataTableReaderListener.cs
- ErrorInfoXmlDocument.cs
- OdbcCommandBuilder.cs
- AmbiguousMatchException.cs
- ConnectionStringSettings.cs
- WindowsGraphics2.cs
- SessionEndedEventArgs.cs
- Pkcs7Recipient.cs
- PackageDigitalSignatureManager.cs
- DrawToolTipEventArgs.cs
- OpenTypeLayout.cs
- NameValueSectionHandler.cs
- SerializationTrace.cs
- HttpErrorTraceRecord.cs
- SafeWaitHandle.cs
- AccessKeyManager.cs
- ProgramNode.cs
- SecureStringHasher.cs
- NavigationEventArgs.cs
- TokenizerHelper.cs
- DrawingAttributes.cs
- ContentType.cs
- TreeNodeSelectionProcessor.cs
- GeneralTransform.cs
- OdbcFactory.cs
- HeaderCollection.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- ResXResourceWriter.cs
- DataGridView.cs
- Pkcs7Recipient.cs
- TransactedBatchContext.cs
- RegularExpressionValidator.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- Peer.cs
- SafeNativeMethods.cs
- PageAction.cs
- ConstraintManager.cs
- ReliableOutputConnection.cs
- _PooledStream.cs
- ThemeInfoAttribute.cs
- MessageHeaderT.cs
- XmlNotation.cs
- FontNamesConverter.cs
- RefExpr.cs
- DataGridTablesFactory.cs
- SqlFacetAttribute.cs
- RadioButtonList.cs
- DataGridViewCell.cs
- DataGridViewCell.cs
- TimeSpanValidator.cs
- BindingContext.cs
- StringInfo.cs
- LazyLoadBehavior.cs
- DbParameterCollection.cs
- TemplatedMailWebEventProvider.cs
- ObjRef.cs
- _OSSOCK.cs
- ErrorFormatterPage.cs
- StylusCollection.cs
- MenuItemBinding.cs
- FileDialog.cs
- AncillaryOps.cs
- ToolStripHighContrastRenderer.cs
- WebPartTransformerCollection.cs
- LinkDescriptor.cs
- HitTestResult.cs
- SimpleLine.cs
- ProxyHelper.cs
- EncryptedReference.cs
- AVElementHelper.cs
- SqlHelper.cs
- WorkflowItemsPresenter.cs
- XPathBuilder.cs
- ReadOnlyNameValueCollection.cs
- BlurBitmapEffect.cs
- SpecularMaterial.cs
- BindingMemberInfo.cs
- TypeResolvingOptions.cs
- MachineSettingsSection.cs
- XmlImplementation.cs
- OdbcFactory.cs
- RtfToken.cs
- HtmlTableCell.cs
- JapaneseLunisolarCalendar.cs
- ToolStripControlHost.cs
- ColumnHeaderCollectionEditor.cs
- InitialServerConnectionReader.cs
- ListViewPagedDataSource.cs
- FileDialog_Vista_Interop.cs
- Int32RectConverter.cs
- ViewPort3D.cs
- Tablet.cs
- MinMaxParagraphWidth.cs
- ToolStripItemClickedEventArgs.cs
- RootDesignerSerializerAttribute.cs
- TemplateKey.cs