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
- Grant.cs
- Viewport3DAutomationPeer.cs
- LinqDataSourceSelectEventArgs.cs
- StringValueSerializer.cs
- TextContainer.cs
- InvokeMethodDesigner.xaml.cs
- XPathNavigatorReader.cs
- MaskedTextProvider.cs
- OdbcError.cs
- SEHException.cs
- UTF8Encoding.cs
- ContextQuery.cs
- TransformProviderWrapper.cs
- RequestCachePolicyConverter.cs
- DateTimeSerializationSection.cs
- Message.cs
- KnownTypesProvider.cs
- DoubleMinMaxAggregationOperator.cs
- OleDbParameter.cs
- OdbcException.cs
- MasterPage.cs
- PrintDialog.cs
- DesignerGenericWebPart.cs
- XmlDictionaryString.cs
- IntellisenseTextBox.cs
- IconHelper.cs
- SafeNativeMethods.cs
- Triplet.cs
- ProviderSettingsCollection.cs
- HyperLinkColumn.cs
- XmlSerializerFactory.cs
- AutoGeneratedFieldProperties.cs
- srgsitem.cs
- ResponseBodyWriter.cs
- ResXBuildProvider.cs
- HierarchicalDataBoundControlAdapter.cs
- ParallelForEach.cs
- BitmapInitialize.cs
- Polygon.cs
- OleDbDataAdapter.cs
- DiscoveryClientChannelBase.cs
- LineProperties.cs
- PenThreadWorker.cs
- NullableDoubleSumAggregationOperator.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- RoutedCommand.cs
- RefreshEventArgs.cs
- XmlAtomicValue.cs
- SqlDataReaderSmi.cs
- DataStorage.cs
- GroupBoxAutomationPeer.cs
- ThreadAttributes.cs
- mil_sdk_version.cs
- EnumerableValidator.cs
- SoapReflectionImporter.cs
- SemaphoreSecurity.cs
- BasicExpandProvider.cs
- EventSetter.cs
- DropDownButton.cs
- ContentElementAutomationPeer.cs
- SqlParameterizer.cs
- CodeTypeReferenceExpression.cs
- SapiGrammar.cs
- CompressionTransform.cs
- InternalBufferManager.cs
- ExtendedPropertyDescriptor.cs
- Maps.cs
- StrokeNode.cs
- HandleRef.cs
- RSACryptoServiceProvider.cs
- DefaultValueTypeConverter.cs
- DbSourceParameterCollection.cs
- DescriptionAttribute.cs
- WebPartCancelEventArgs.cs
- MediaScriptCommandRoutedEventArgs.cs
- __TransparentProxy.cs
- XamlStyleSerializer.cs
- DispatcherExceptionEventArgs.cs
- RsaSecurityTokenAuthenticator.cs
- OutputCacheProfile.cs
- BigInt.cs
- ConvertEvent.cs
- ListView.cs
- DataGridRowClipboardEventArgs.cs
- LicenseProviderAttribute.cs
- _AcceptOverlappedAsyncResult.cs
- Drawing.cs
- Quaternion.cs
- Transform.cs
- FormattedTextSymbols.cs
- QilInvoke.cs
- EventEntry.cs
- RelationshipEnd.cs
- StringExpressionSet.cs
- BidPrivateBase.cs
- DataServiceQuery.cs
- XslTransform.cs
- DefaultSection.cs
- CollectionDataContract.cs
- OleDbRowUpdatedEvent.cs