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
- Vector3DConverter.cs
- MouseActionConverter.cs
- StateMachineAction.cs
- SelectionRangeConverter.cs
- MetadataArtifactLoaderResource.cs
- ArraySortHelper.cs
- StringFunctions.cs
- FlowLayoutPanel.cs
- unsafenativemethodsother.cs
- NotImplementedException.cs
- ApplicationActivator.cs
- MergePropertyDescriptor.cs
- AssertSection.cs
- SelectionItemPattern.cs
- Zone.cs
- TrustLevelCollection.cs
- DBPropSet.cs
- DocumentApplicationJournalEntry.cs
- AutomationElementCollection.cs
- TracedNativeMethods.cs
- GraphicsState.cs
- ProgressPage.cs
- StyleHelper.cs
- PrivateFontCollection.cs
- ErrorWrapper.cs
- DataGridViewLinkColumn.cs
- ControlBindingsCollection.cs
- SoapException.cs
- ScriptDescriptor.cs
- CFGGrammar.cs
- ToolStripDropDown.cs
- SqlDataSourceCommandParser.cs
- HeaderedItemsControl.cs
- BasicBrowserDialog.designer.cs
- HostingPreferredMapPath.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- RegionInfo.cs
- SecurityElement.cs
- IntSumAggregationOperator.cs
- Ipv6Element.cs
- SqlServices.cs
- ObjectViewListener.cs
- SchemaTableOptionalColumn.cs
- OleDbDataReader.cs
- IIS7WorkerRequest.cs
- SqlMethodAttribute.cs
- ImageField.cs
- XamlToRtfWriter.cs
- _SafeNetHandles.cs
- OptimalBreakSession.cs
- ModuleBuilder.cs
- DataGridViewCellValidatingEventArgs.cs
- ScriptReference.cs
- BaseCollection.cs
- COM2Enum.cs
- HandleExceptionArgs.cs
- Selector.cs
- DataGridAddNewRow.cs
- BuilderInfo.cs
- EventBuilder.cs
- DbConnectionPoolCounters.cs
- DataControlButton.cs
- SqlRowUpdatingEvent.cs
- ObjectItemCollection.cs
- XmlSchemaInfo.cs
- DataGridViewEditingControlShowingEventArgs.cs
- Update.cs
- NavigateEvent.cs
- InternalSafeNativeMethods.cs
- SqlXml.cs
- cryptoapiTransform.cs
- ImageResources.Designer.cs
- ByteStorage.cs
- HTMLTextWriter.cs
- Pair.cs
- RemoteWebConfigurationHostStream.cs
- ReadOnlyCollectionBuilder.cs
- PerformanceCounterCategory.cs
- ToolStripGripRenderEventArgs.cs
- XPathQilFactory.cs
- Operator.cs
- WorkItem.cs
- UnsafeNativeMethods.cs
- NativeMethods.cs
- RegularExpressionValidator.cs
- SafeNativeMethods.cs
- SchemaConstraints.cs
- FileSystemEventArgs.cs
- EmptyStringExpandableObjectConverter.cs
- ValueHandle.cs
- UnsafePeerToPeerMethods.cs
- webclient.cs
- OutputCacheSettingsSection.cs
- MenuAutoFormat.cs
- BaseInfoTable.cs
- Journal.cs
- UIElementPropertyUndoUnit.cs
- MultiByteCodec.cs
- Cursors.cs
- BufferedStream.cs