Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / Primitives / SelectiveScrollingGrid.cs / 1305600 / SelectiveScrollingGrid.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; namespace System.Windows.Controls.Primitives { ////// Subclass of Grid that knows how to freeze certain cells in place when scrolled. /// Used as the panel for the DataGridRow to hold the header, cells, and details. /// public class SelectiveScrollingGrid : Grid { ////// Attached property to specify the selective scroll behaviour of cells /// public static readonly DependencyProperty SelectiveScrollin----entationProperty = DependencyProperty.RegisterAttached( "SelectiveScrollin----entation", typeof(SelectiveScrollin----entation), typeof(SelectiveScrollingGrid), new FrameworkPropertyMetadata(SelectiveScrollin----entation.Both, new PropertyChangedCallback(OnSelectiveScrollin----entationChanged))); ////// Getter for the SelectiveScrollin----entation attached property /// /// ///public static SelectiveScrollin----entation GetSelectiveScrollin----entation(DependencyObject obj) { return (SelectiveScrollin----entation)obj.GetValue(SelectiveScrollin----entationProperty); } /// /// Setter for the SelectiveScrollin----entation attached property /// /// /// public static void SetSelectiveScrollin----entation(DependencyObject obj, SelectiveScrollin----entation value) { obj.SetValue(SelectiveScrollin----entationProperty, value); } ////// Property changed call back for SelectiveScrollin----entation property /// /// /// private static void OnSelectiveScrollin----entationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UIElement element = d as UIElement; SelectiveScrollin----entation orientation = (SelectiveScrollin----entation)e.NewValue; ScrollViewer scrollViewer = DataGridHelper.FindVisualParent(element); if (scrollViewer != null && element != null) { Transform transform = element.RenderTransform; if (transform != null) { BindingOperations.ClearBinding(transform, TranslateTransform.XProperty); BindingOperations.ClearBinding(transform, TranslateTransform.YProperty); } if (orientation == SelectiveScrollin----entation.Both) { element.RenderTransform = null; } else { TranslateTransform translateTransform = new TranslateTransform(); // Add binding to XProperty of transform if orientation is not horizontal if (orientation != SelectiveScrollin----entation.Horizontal) { Binding horizontalBinding = new Binding("ContentHorizontalOffset"); horizontalBinding.Source = scrollViewer; BindingOperations.SetBinding(translateTransform, TranslateTransform.XProperty, horizontalBinding); } // Add binding to YProperty of transfrom if orientation is not vertical if (orientation != SelectiveScrollin----entation.Vertical) { Binding verticalBinding = new Binding("ContentVerticalOffset"); verticalBinding.Source = scrollViewer; BindingOperations.SetBinding(translateTransform, TranslateTransform.YProperty, verticalBinding); } element.RenderTransform = translateTransform; } } } } } // 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.Controls; using System.Windows.Data; using System.Windows.Media; namespace System.Windows.Controls.Primitives { /// /// Subclass of Grid that knows how to freeze certain cells in place when scrolled. /// Used as the panel for the DataGridRow to hold the header, cells, and details. /// public class SelectiveScrollingGrid : Grid { ////// Attached property to specify the selective scroll behaviour of cells /// public static readonly DependencyProperty SelectiveScrollin----entationProperty = DependencyProperty.RegisterAttached( "SelectiveScrollin----entation", typeof(SelectiveScrollin----entation), typeof(SelectiveScrollingGrid), new FrameworkPropertyMetadata(SelectiveScrollin----entation.Both, new PropertyChangedCallback(OnSelectiveScrollin----entationChanged))); ////// Getter for the SelectiveScrollin----entation attached property /// /// ///public static SelectiveScrollin----entation GetSelectiveScrollin----entation(DependencyObject obj) { return (SelectiveScrollin----entation)obj.GetValue(SelectiveScrollin----entationProperty); } /// /// Setter for the SelectiveScrollin----entation attached property /// /// /// public static void SetSelectiveScrollin----entation(DependencyObject obj, SelectiveScrollin----entation value) { obj.SetValue(SelectiveScrollin----entationProperty, value); } ////// Property changed call back for SelectiveScrollin----entation property /// /// /// private static void OnSelectiveScrollin----entationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UIElement element = d as UIElement; SelectiveScrollin----entation orientation = (SelectiveScrollin----entation)e.NewValue; ScrollViewer scrollViewer = DataGridHelper.FindVisualParent(element); if (scrollViewer != null && element != null) { Transform transform = element.RenderTransform; if (transform != null) { BindingOperations.ClearBinding(transform, TranslateTransform.XProperty); BindingOperations.ClearBinding(transform, TranslateTransform.YProperty); } if (orientation == SelectiveScrollin----entation.Both) { element.RenderTransform = null; } else { TranslateTransform translateTransform = new TranslateTransform(); // Add binding to XProperty of transform if orientation is not horizontal if (orientation != SelectiveScrollin----entation.Horizontal) { Binding horizontalBinding = new Binding("ContentHorizontalOffset"); horizontalBinding.Source = scrollViewer; BindingOperations.SetBinding(translateTransform, TranslateTransform.XProperty, horizontalBinding); } // Add binding to YProperty of transfrom if orientation is not vertical if (orientation != SelectiveScrollin----entation.Vertical) { Binding verticalBinding = new Binding("ContentVerticalOffset"); verticalBinding.Source = scrollViewer; BindingOperations.SetBinding(translateTransform, TranslateTransform.YProperty, verticalBinding); } element.RenderTransform = translateTransform; } } } } } // 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
- CornerRadius.cs
- TextSelectionHelper.cs
- EdmItemCollection.cs
- AdPostCacheSubstitution.cs
- COM2Enum.cs
- TreeViewAutomationPeer.cs
- WindowsServiceCredential.cs
- CompilationLock.cs
- ExtentCqlBlock.cs
- VisualBrush.cs
- BounceEase.cs
- ZoneMembershipCondition.cs
- sortedlist.cs
- metadatamappinghashervisitor.cs
- RawStylusInputReport.cs
- SchemaMapping.cs
- GPPOINTF.cs
- ScriptMethodAttribute.cs
- DataKeyCollection.cs
- util.cs
- XmlStreamStore.cs
- CommandDevice.cs
- HtmlControlPersistable.cs
- CultureNotFoundException.cs
- PersonalizationAdministration.cs
- QuaternionValueSerializer.cs
- SqlCharStream.cs
- SessionStateModule.cs
- LongValidator.cs
- Parameter.cs
- SecurityTokenRequirement.cs
- TextEditorParagraphs.cs
- ReferenceConverter.cs
- UpdateCommand.cs
- PaperSource.cs
- ObjectMaterializedEventArgs.cs
- SignedXml.cs
- SqlRowUpdatedEvent.cs
- OperationParameterInfoCollection.cs
- SQLGuid.cs
- ZipIOExtraFieldElement.cs
- QilTargetType.cs
- MustUnderstandSoapException.cs
- ExpressionEditorAttribute.cs
- CodeChecksumPragma.cs
- ArithmeticException.cs
- ProvidersHelper.cs
- ScrollEvent.cs
- EntitySetDataBindingList.cs
- UIElementParagraph.cs
- PlainXmlSerializer.cs
- PassportAuthentication.cs
- Pts.cs
- SectionInformation.cs
- SystemResourceKey.cs
- Exceptions.cs
- Block.cs
- Literal.cs
- BitmapFrameDecode.cs
- SecurityDescriptor.cs
- MetadataItem.cs
- Storyboard.cs
- Point3D.cs
- LassoSelectionBehavior.cs
- TransformConverter.cs
- DetailsViewRow.cs
- wmiprovider.cs
- ObjectDataSourceEventArgs.cs
- AssemblyCollection.cs
- ParenthesizePropertyNameAttribute.cs
- SafeRightsManagementPubHandle.cs
- OptimizedTemplateContentHelper.cs
- QuaternionConverter.cs
- DefaultMemberAttribute.cs
- ComponentTray.cs
- ParseNumbers.cs
- CqlErrorHelper.cs
- LocalIdCollection.cs
- ToolStripDropDownClosingEventArgs.cs
- StandardToolWindows.cs
- MetabaseServerConfig.cs
- StaticDataManager.cs
- TailCallAnalyzer.cs
- TraceSection.cs
- XmlQueryRuntime.cs
- TransportDefaults.cs
- IpcPort.cs
- OletxResourceManager.cs
- UInt32Converter.cs
- FastEncoderStatics.cs
- ToolTipService.cs
- StringDictionaryCodeDomSerializer.cs
- AsyncStreamReader.cs
- AttachmentCollection.cs
- DbLambda.cs
- DbConnectionStringCommon.cs
- LicenseException.cs
- SkewTransform.cs
- RelationshipManager.cs
- UpdateTranslator.cs