Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Converters / ObjectToModelValueConverter.cs / 1305376 / ObjectToModelValueConverter.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Converters { using System.Diagnostics; using System.Globalization; using System.Windows.Data; using System.Activities.Presentation.Model; using System.Activities.Presentation.Internal.PropertyEditing.Model; //This value converter is used in propertygrid scenarios to convert an object into a ModelItem. //It converts from ModelPropertyEntry to ModelItem that owns the property //The first binding is a two way binding with the PropertyValue object //The second binding is a one way binding with the ModelPropertyEntry. public class ObjectToModelValueConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ModelItem convertedValue = null; if (values[1] != null) { ModelPropertyEntry modelPropertyEntry = values[1] as ModelPropertyEntry; if (modelPropertyEntry != null) { ModelProperty property = modelPropertyEntry.FirstModelProperty; if (property != null) { convertedValue = property.Value; } } } return convertedValue; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { object[] returnValue = new object[]{null}; if(value != null) { returnValue[0] = ((ModelItem)value).GetCurrentValue(); } return returnValue; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Converters { using System.Diagnostics; using System.Globalization; using System.Windows.Data; using System.Activities.Presentation.Model; using System.Activities.Presentation.Internal.PropertyEditing.Model; //This value converter is used in propertygrid scenarios to convert an object into a ModelItem. //It converts from ModelPropertyEntry to ModelItem that owns the property //The first binding is a two way binding with the PropertyValue object //The second binding is a one way binding with the ModelPropertyEntry. public class ObjectToModelValueConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ModelItem convertedValue = null; if (values[1] != null) { ModelPropertyEntry modelPropertyEntry = values[1] as ModelPropertyEntry; if (modelPropertyEntry != null) { ModelProperty property = modelPropertyEntry.FirstModelProperty; if (property != null) { convertedValue = property.Value; } } } return convertedValue; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { object[] returnValue = new object[]{null}; if(value != null) { returnValue[0] = ((ModelItem)value).GetCurrentValue(); } return returnValue; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Stroke2.cs
- DataBindingsDialog.cs
- FloatAverageAggregationOperator.cs
- Camera.cs
- CompilationUnit.cs
- AlphabetConverter.cs
- brushes.cs
- XmlEncoding.cs
- ReadWriteObjectLock.cs
- GridViewCommandEventArgs.cs
- Rect3DConverter.cs
- XmlMtomReader.cs
- EventRoute.cs
- ObjectAnimationUsingKeyFrames.cs
- PrinterResolution.cs
- FixedDSBuilder.cs
- QueueException.cs
- VersionPair.cs
- FindRequestContext.cs
- BinaryExpressionHelper.cs
- BuiltInExpr.cs
- AuthorizationRule.cs
- ProxyWebPartManager.cs
- SingleStorage.cs
- _HelperAsyncResults.cs
- TextRange.cs
- InvalidCastException.cs
- ContextMenu.cs
- BuiltInExpr.cs
- EllipseGeometry.cs
- QilParameter.cs
- FontEmbeddingManager.cs
- MemberJoinTreeNode.cs
- ConfigXmlSignificantWhitespace.cs
- CodeCompiler.cs
- XmlSchemaType.cs
- DoubleIndependentAnimationStorage.cs
- ExtensionWindow.cs
- WebRequestModuleElementCollection.cs
- SingleObjectCollection.cs
- DBConnectionString.cs
- CheckBoxList.cs
- QueryOperationResponseOfT.cs
- EventLogTraceListener.cs
- OdbcCommand.cs
- XslTransform.cs
- SafeHandles.cs
- DefaultShape.cs
- _OSSOCK.cs
- InputLangChangeRequestEvent.cs
- DataGridSortingEventArgs.cs
- Events.cs
- SqlDataAdapter.cs
- ObjectViewFactory.cs
- CharConverter.cs
- BamlTreeMap.cs
- TextBounds.cs
- KeysConverter.cs
- HttpStreams.cs
- CollectionEditorDialog.cs
- ImageSourceValueSerializer.cs
- MediaContextNotificationWindow.cs
- MemberListBinding.cs
- FontResourceCache.cs
- ScrollEventArgs.cs
- Propagator.JoinPropagator.cs
- IListConverters.cs
- TypeSystem.cs
- ExpressionParser.cs
- _CommandStream.cs
- WorkflowClientDeliverMessageWrapper.cs
- NavigationEventArgs.cs
- Point3DCollectionConverter.cs
- PageCatalogPart.cs
- CodeIndexerExpression.cs
- MissingFieldException.cs
- RsaSecurityKey.cs
- AutoGeneratedField.cs
- MaterialCollection.cs
- SubordinateTransaction.cs
- ReadOnlyDictionary.cs
- XsltLibrary.cs
- HtmlElementErrorEventArgs.cs
- SecurityPermission.cs
- Translator.cs
- UnsafeNativeMethods.cs
- CodeTypeDeclaration.cs
- SystemInformation.cs
- DiffuseMaterial.cs
- ImageSource.cs
- RectangleConverter.cs
- CompilerLocalReference.cs
- TableLayoutPanelCodeDomSerializer.cs
- ExcludePathInfo.cs
- PerformanceCounterCategory.cs
- DataGridViewCellEventArgs.cs
- Package.cs
- _FtpDataStream.cs
- DoubleAnimationClockResource.cs
- RightsDocument.cs