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
- ProbeDuplexAsyncResult.cs
- DnsPermission.cs
- WorkflowServiceAttributes.cs
- DeviceContext.cs
- HeaderElement.cs
- CodeGenerator.cs
- DataServiceProviderMethods.cs
- XmlDomTextWriter.cs
- PinnedBufferMemoryStream.cs
- dbenumerator.cs
- ButtonPopupAdapter.cs
- RIPEMD160.cs
- OdbcPermission.cs
- ViewStateModeByIdAttribute.cs
- StyleSheet.cs
- IHttpResponseInternal.cs
- ListItem.cs
- TemplateInstanceAttribute.cs
- WebRequest.cs
- JavaScriptObjectDeserializer.cs
- QilStrConcatenator.cs
- _NtlmClient.cs
- SEHException.cs
- TrackingRecordPreFilter.cs
- PrintController.cs
- DocumentPageHost.cs
- XmlResolver.cs
- CodeTypeParameterCollection.cs
- brushes.cs
- CmsInterop.cs
- Thread.cs
- ObservableCollectionDefaultValueFactory.cs
- DataRowIndexBuffer.cs
- Utility.cs
- GeneralTransformCollection.cs
- CommonDialog.cs
- MonitoringDescriptionAttribute.cs
- SizeConverter.cs
- WebPartTransformer.cs
- RegisteredArrayDeclaration.cs
- EventLogPermissionEntryCollection.cs
- CodeDomSerializerException.cs
- __TransparentProxy.cs
- PackWebRequestFactory.cs
- Resources.Designer.cs
- SynchronizationHandlesCodeDomSerializer.cs
- SmiRecordBuffer.cs
- SqlProviderManifest.cs
- coordinatorscratchpad.cs
- DelayedRegex.cs
- _CacheStreams.cs
- CultureInfo.cs
- DiagnosticsConfiguration.cs
- UriSectionReader.cs
- ClientBuildManagerCallback.cs
- TabItemAutomationPeer.cs
- PrimitiveOperationFormatter.cs
- MonthChangedEventArgs.cs
- PeerCollaboration.cs
- WindowsRegion.cs
- SoapFault.cs
- JsonSerializer.cs
- EventMemberCodeDomSerializer.cs
- Fx.cs
- ServiceInfoCollection.cs
- SessionSwitchEventArgs.cs
- FileNotFoundException.cs
- SwitchElementsCollection.cs
- InlineObject.cs
- XmlName.cs
- Clause.cs
- SafeFileMappingHandle.cs
- DataControlFieldCell.cs
- ProvidePropertyAttribute.cs
- DoubleCollectionConverter.cs
- Transform.cs
- StylusSystemGestureEventArgs.cs
- ExplicitDiscriminatorMap.cs
- DashStyle.cs
- StrokeRenderer.cs
- SqlException.cs
- CodeArrayCreateExpression.cs
- XpsPackagingPolicy.cs
- RequestTimeoutManager.cs
- DiscardableAttribute.cs
- SystemInformation.cs
- SqlTriggerAttribute.cs
- SizeValueSerializer.cs
- CellPartitioner.cs
- AuthStoreRoleProvider.cs
- MappingModelBuildProvider.cs
- WinFormsComponentEditor.cs
- ViewgenContext.cs
- EventLogger.cs
- QueryableDataSourceEditData.cs
- DataGridPagerStyle.cs
- BooleanProjectedSlot.cs
- AccessedThroughPropertyAttribute.cs
- WebPartEventArgs.cs
- UserControlDesigner.cs