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
- PathSegmentCollection.cs
- Matrix3DValueSerializer.cs
- ReservationCollection.cs
- DecimalConstantAttribute.cs
- BigInt.cs
- ToolStripTextBox.cs
- TextRangeBase.cs
- ListBoxChrome.cs
- FindCriteria.cs
- SyntaxCheck.cs
- TemplateBaseAction.cs
- GiveFeedbackEventArgs.cs
- AdPostCacheSubstitution.cs
- ClientSettingsSection.cs
- RSAPKCS1KeyExchangeFormatter.cs
- FilteredXmlReader.cs
- BrowserInteropHelper.cs
- ModifierKeysValueSerializer.cs
- VarRemapper.cs
- UnorderedHashRepartitionStream.cs
- XmlSubtreeReader.cs
- MessageBox.cs
- InvalidAsynchronousStateException.cs
- UserNamePasswordValidator.cs
- XmlSignatureManifest.cs
- SectionInput.cs
- SHA384CryptoServiceProvider.cs
- Transform3D.cs
- WmlLabelAdapter.cs
- Overlapped.cs
- SecurityUniqueId.cs
- CultureInfoConverter.cs
- WebPartCollection.cs
- ModelVisual3D.cs
- UmAlQuraCalendar.cs
- WCFBuildProvider.cs
- FrugalList.cs
- SpecularMaterial.cs
- ConstraintCollection.cs
- Cloud.cs
- SqlProfileProvider.cs
- SearchForVirtualItemEventArgs.cs
- DiscoveryDocumentSerializer.cs
- TriggerCollection.cs
- EntityDataSourceState.cs
- HandleRef.cs
- BaseAsyncResult.cs
- Overlapped.cs
- DataGridLengthConverter.cs
- SQLDouble.cs
- AddInEnvironment.cs
- DataGridSortCommandEventArgs.cs
- HyperLinkColumn.cs
- CodeCastExpression.cs
- ObjectDataSourceMethodEventArgs.cs
- ConfigurationSchemaErrors.cs
- WindowsGraphics2.cs
- Rights.cs
- ListControlConvertEventArgs.cs
- SqlNodeAnnotation.cs
- CollectionBuilder.cs
- ObjectConverter.cs
- TableRowCollection.cs
- BasicCommandTreeVisitor.cs
- CategoryList.cs
- PageAdapter.cs
- SubpageParaClient.cs
- WebHttpEndpointElement.cs
- XmlNotation.cs
- ToolStripSplitButton.cs
- PersonalizationAdministration.cs
- DependencyPropertyConverter.cs
- DBCommandBuilder.cs
- Variant.cs
- TrackingMemoryStreamFactory.cs
- ProcessHostMapPath.cs
- SoapException.cs
- Style.cs
- ErasingStroke.cs
- TextComposition.cs
- XmlSchemaComplexContent.cs
- TripleDES.cs
- RawStylusInput.cs
- VersionedStreamOwner.cs
- IdentifierService.cs
- MetadataCacheItem.cs
- LabelDesigner.cs
- UITypeEditors.cs
- FloaterBaseParaClient.cs
- DashStyle.cs
- MimeTypeMapper.cs
- ResumeStoryboard.cs
- System.Data_BID.cs
- SymmetricKeyWrap.cs
- PropertyCollection.cs
- ConnectorDragDropGlyph.cs
- XmlComplianceUtil.cs
- WindowsSidIdentity.cs
- QilXmlWriter.cs
- TextDecoration.cs