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
- RadioButton.cs
- IItemContainerGenerator.cs
- Latin1Encoding.cs
- RegexReplacement.cs
- Image.cs
- WebBrowsableAttribute.cs
- VisualBrush.cs
- TemplatedMailWebEventProvider.cs
- DesignTable.cs
- DispatchWrapper.cs
- DispatcherHookEventArgs.cs
- StrokeCollection2.cs
- ComponentManagerBroker.cs
- TdsValueSetter.cs
- EntityDataSourceState.cs
- AppliedDeviceFiltersEditor.cs
- Span.cs
- CertificateReferenceElement.cs
- XamlVector3DCollectionSerializer.cs
- Pair.cs
- ConfigurationStrings.cs
- ComponentDesigner.cs
- OutputCacheEntry.cs
- VirtualizingStackPanel.cs
- ScalarOps.cs
- VSWCFServiceContractGenerator.cs
- TakeQueryOptionExpression.cs
- DBProviderConfigurationHandler.cs
- ISAPIApplicationHost.cs
- WebPartTracker.cs
- RelationshipFixer.cs
- LoaderAllocator.cs
- DispatcherProcessingDisabled.cs
- URLMembershipCondition.cs
- StyleXamlParser.cs
- SBCSCodePageEncoding.cs
- ActivityTypeResolver.xaml.cs
- RequestContext.cs
- WizardDesigner.cs
- OrderablePartitioner.cs
- SoundPlayerAction.cs
- DataGridHyperlinkColumn.cs
- _ListenerAsyncResult.cs
- XmlNamespaceMapping.cs
- CalendarModeChangedEventArgs.cs
- AppSettingsExpressionBuilder.cs
- MenuItemAutomationPeer.cs
- PerfCounters.cs
- SHA256Managed.cs
- ObjectDataSourceSelectingEventArgs.cs
- WindowsStreamSecurityElement.cs
- CompoundFileStreamReference.cs
- CookieParameter.cs
- ItemCollection.cs
- SystemWebExtensionsSectionGroup.cs
- CoreSwitches.cs
- CompositeFontFamily.cs
- FacetValues.cs
- Transform3DGroup.cs
- ComboBox.cs
- SiteOfOriginContainer.cs
- ModelTreeEnumerator.cs
- SqlReorderer.cs
- RegularExpressionValidator.cs
- Material.cs
- SQLDecimalStorage.cs
- ManagementEventArgs.cs
- StyleModeStack.cs
- XmlDocumentSchema.cs
- ButtonPopupAdapter.cs
- CodeSnippetTypeMember.cs
- ECDiffieHellman.cs
- StringSource.cs
- AuthenticationModulesSection.cs
- FormatVersion.cs
- xmlglyphRunInfo.cs
- AlphabeticalEnumConverter.cs
- XmlAnyElementAttribute.cs
- Cloud.cs
- SoapEnumAttribute.cs
- OleDbRowUpdatedEvent.cs
- SqlBulkCopyColumnMappingCollection.cs
- FormatSelectingMessageInspector.cs
- parserscommon.cs
- XmlValueConverter.cs
- ObjectQueryProvider.cs
- SizeKeyFrameCollection.cs
- ServicesUtilities.cs
- Composition.cs
- RegexCharClass.cs
- WizardDesigner.cs
- InvalidComObjectException.cs
- SegmentInfo.cs
- FilteredAttributeCollection.cs
- SqlBulkCopyColumnMapping.cs
- HasCopySemanticsAttribute.cs
- GroupBox.cs
- OleDbParameterCollection.cs
- DocumentPaginator.cs
- PropertyReferenceSerializer.cs