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
- WinFormsSpinner.cs
- PageContent.cs
- HttpRawResponse.cs
- TransactionManager.cs
- ReverseInheritProperty.cs
- WebPageTraceListener.cs
- KnownColorTable.cs
- RadioButtonFlatAdapter.cs
- X509InitiatorCertificateServiceElement.cs
- EmbossBitmapEffect.cs
- NavigationCommands.cs
- SerializationFieldInfo.cs
- HtmlInputHidden.cs
- BaseInfoTable.cs
- RadioButtonBaseAdapter.cs
- StringResourceManager.cs
- XmlSchemaElement.cs
- recordstatescratchpad.cs
- TextServicesLoader.cs
- SerializationAttributes.cs
- TableSectionStyle.cs
- PrtCap_Public_Simple.cs
- LineBreakRecord.cs
- Tag.cs
- FileUtil.cs
- IsolatedStorageException.cs
- EntityFunctions.cs
- ObjectDataSourceDisposingEventArgs.cs
- ContactManager.cs
- XPathNodePointer.cs
- SafeEventHandle.cs
- TypeExtension.cs
- LockRecoveryTask.cs
- LocalizationComments.cs
- MimeBasePart.cs
- Validator.cs
- ProjectionNode.cs
- DataTransferEventArgs.cs
- CheckoutException.cs
- ConfigPathUtility.cs
- XPathItem.cs
- ValidationSummary.cs
- SqlCacheDependencyDatabaseCollection.cs
- XpsTokenContext.cs
- ConnectionConsumerAttribute.cs
- ContextMenuStrip.cs
- PreProcessInputEventArgs.cs
- PerformanceCounterPermissionEntry.cs
- ScrollData.cs
- UserControl.cs
- RangeContentEnumerator.cs
- PropertyPath.cs
- IDispatchConstantAttribute.cs
- ChannelManager.cs
- sitestring.cs
- SystemUdpStatistics.cs
- XpsFilter.cs
- KeyConverter.cs
- BuildResult.cs
- Base64Stream.cs
- Hex.cs
- HuffCodec.cs
- ResourcePart.cs
- WindowsNonControl.cs
- OciHandle.cs
- WebBrowserNavigatedEventHandler.cs
- TextSelectionHighlightLayer.cs
- InvalidPropValue.cs
- ModuleBuilder.cs
- PolicyManager.cs
- ActivityExecutionContextCollection.cs
- StandardToolWindows.cs
- Brush.cs
- PermissionSetEnumerator.cs
- ExpressionBuilderCollection.cs
- Transactions.cs
- MetadataItemEmitter.cs
- DelegateSerializationHolder.cs
- Validator.cs
- GlyphRunDrawing.cs
- WmlValidatorAdapter.cs
- TypeContext.cs
- ParallelQuery.cs
- SpeechUI.cs
- MatrixConverter.cs
- lengthconverter.cs
- StrokeNode.cs
- EncryptedData.cs
- SessionState.cs
- SingleObjectCollection.cs
- Int32CollectionValueSerializer.cs
- RangeValidator.cs
- ReflectionHelper.cs
- SoapSchemaImporter.cs
- SafeLibraryHandle.cs
- SHA256CryptoServiceProvider.cs
- SqlWebEventProvider.cs
- ResourceIDHelper.cs
- AxisAngleRotation3D.cs
- HttpServerUtilityBase.cs