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
- Math.cs
- CustomExpression.cs
- WorkerProcess.cs
- LinkClickEvent.cs
- RequestCachePolicyConverter.cs
- TreeViewDesigner.cs
- SafeSecurityHandles.cs
- EntityDataSourceContextCreatedEventArgs.cs
- LinkUtilities.cs
- IriParsingElement.cs
- BaseEntityWrapper.cs
- Win32.cs
- Manipulation.cs
- MissingMemberException.cs
- UnsafeNativeMethods.cs
- TrustManager.cs
- AuthenticateEventArgs.cs
- DataGridViewHeaderCell.cs
- XmlILIndex.cs
- TextAnchor.cs
- ColumnTypeConverter.cs
- WindowShowOrOpenTracker.cs
- ToolStripRendererSwitcher.cs
- PrintDialogException.cs
- DataRecordInternal.cs
- Int32Rect.cs
- Metafile.cs
- TreeViewCancelEvent.cs
- GenericIdentity.cs
- SQLBinary.cs
- TextSchema.cs
- SHA512Managed.cs
- XmlnsPrefixAttribute.cs
- ContentElement.cs
- FileDataSourceCache.cs
- CodeTypeDelegate.cs
- InvokeProviderWrapper.cs
- ChangeConflicts.cs
- DataRowView.cs
- ObjectItemNoOpAssemblyLoader.cs
- WorkflowServiceBehavior.cs
- NavigationPropertyEmitter.cs
- AccessKeyManager.cs
- GeneralEndpointIdentity.cs
- remotingproxy.cs
- SizeAnimationUsingKeyFrames.cs
- InstanceDataCollectionCollection.cs
- DataServices.cs
- AddInProcess.cs
- ForeignKeyFactory.cs
- HorizontalAlignConverter.cs
- ConfigXmlCDataSection.cs
- NumericUpDownAcceleration.cs
- ISAPIWorkerRequest.cs
- XmlILCommand.cs
- QueryConverter.cs
- AutoResizedEvent.cs
- IPHostEntry.cs
- GestureRecognizer.cs
- EpmCustomContentWriterNodeData.cs
- ResourceSet.cs
- RecognizerStateChangedEventArgs.cs
- OleDbPermission.cs
- RelationalExpressions.cs
- DataGridViewRowsRemovedEventArgs.cs
- LoginUtil.cs
- WindowsStatusBar.cs
- BaseDataBoundControl.cs
- ColorPalette.cs
- SchemeSettingElementCollection.cs
- WinEventQueueItem.cs
- LZCodec.cs
- UrlUtility.cs
- InfoCardRSACryptoProvider.cs
- OdbcError.cs
- AlternationConverter.cs
- DesignerDeviceConfig.cs
- MemberDescriptor.cs
- XmlILAnnotation.cs
- ping.cs
- AutomationPeer.cs
- Path.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- PropertyNames.cs
- BuiltInExpr.cs
- AttachedAnnotationChangedEventArgs.cs
- DynamicControlParameter.cs
- XmlDownloadManager.cs
- DESCryptoServiceProvider.cs
- EntityDataSourceDesignerHelper.cs
- HostingEnvironmentWrapper.cs
- CompatibleComparer.cs
- HttpGetProtocolImporter.cs
- NotifyIcon.cs
- BaseConfigurationRecord.cs
- DesignerVerbCollection.cs
- versioninfo.cs
- Helpers.cs
- StringHandle.cs
- UserControlDesigner.cs