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
- WebPartRestoreVerb.cs
- SessionSwitchEventArgs.cs
- EventMappingSettingsCollection.cs
- PagesSection.cs
- DecoderFallback.cs
- ListViewItemMouseHoverEvent.cs
- BuildTopDownAttribute.cs
- HwndSubclass.cs
- ListItemParagraph.cs
- DBSqlParserColumn.cs
- PropertyEntry.cs
- ExceptionUtil.cs
- MultiBindingExpression.cs
- TreeNodeStyleCollection.cs
- TypeForwardedToAttribute.cs
- Input.cs
- WebBaseEventKeyComparer.cs
- ScopelessEnumAttribute.cs
- IsolatedStorageFilePermission.cs
- CategoryGridEntry.cs
- ResourcePermissionBase.cs
- SchemaEntity.cs
- SamlSerializer.cs
- NewItemsContextMenuStrip.cs
- DeploymentExceptionMapper.cs
- XmlSchemaChoice.cs
- Size3D.cs
- IChannel.cs
- DriveNotFoundException.cs
- CalendarDateRangeChangingEventArgs.cs
- Memoizer.cs
- BlurEffect.cs
- ImmutableObjectAttribute.cs
- Marshal.cs
- BamlStream.cs
- TrackingServices.cs
- _BufferOffsetSize.cs
- DESCryptoServiceProvider.cs
- ObservableCollection.cs
- ACE.cs
- ReadWriteSpinLock.cs
- AudioLevelUpdatedEventArgs.cs
- ControlPager.cs
- CustomBindingElementCollection.cs
- Path.cs
- MasterPage.cs
- HttpHandlerAction.cs
- Cell.cs
- ZipIOCentralDirectoryBlock.cs
- MembershipUser.cs
- ActivityInstance.cs
- WorkItem.cs
- TextTrailingCharacterEllipsis.cs
- TraceSource.cs
- DefinitionUpdate.cs
- Component.cs
- TcpServerChannel.cs
- AddingNewEventArgs.cs
- ChangePasswordDesigner.cs
- VariableQuery.cs
- MultitargetingHelpers.cs
- ProcessProtocolHandler.cs
- QueryableDataSource.cs
- MessagePropertyVariants.cs
- DbConnectionPoolGroup.cs
- ValuePatternIdentifiers.cs
- UInt32.cs
- PenThreadPool.cs
- GlyphRun.cs
- Barrier.cs
- PropertyIDSet.cs
- InputQueue.cs
- TextOnlyOutput.cs
- FunctionParameter.cs
- SettingsPropertyNotFoundException.cs
- WebPartDescription.cs
- Membership.cs
- CapabilitiesSection.cs
- Point.cs
- PenContext.cs
- TemplateBaseAction.cs
- PageThemeParser.cs
- ServiceBusyException.cs
- PortCache.cs
- ExpressionConverter.cs
- MetadataStore.cs
- MenuItemBinding.cs
- WebPartDisplayModeCollection.cs
- HttpHandlerActionCollection.cs
- HashSetEqualityComparer.cs
- WebBrowsableAttribute.cs
- Int32KeyFrameCollection.cs
- UnhandledExceptionEventArgs.cs
- PartitionedDataSource.cs
- JsonClassDataContract.cs
- SimpleApplicationHost.cs
- BuildProviderAppliesToAttribute.cs
- KeyTime.cs
- ListViewItem.cs
- GridPattern.cs