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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InstanceHandle.cs
- Window.cs
- OleDbReferenceCollection.cs
- PenContexts.cs
- Parameter.cs
- CursorConverter.cs
- Compensation.cs
- ActivityDefaults.cs
- RoutedCommand.cs
- ConfigurationSectionGroup.cs
- ApplicationSecurityManager.cs
- RegexParser.cs
- TwoPhaseCommit.cs
- ConnectionsZone.cs
- BindingGroup.cs
- LineSegment.cs
- InvalidOleVariantTypeException.cs
- EventListener.cs
- GroupBoxAutomationPeer.cs
- ShaderEffect.cs
- URL.cs
- AxisAngleRotation3D.cs
- ComplexPropertyEntry.cs
- CacheModeConverter.cs
- _HelperAsyncResults.cs
- DynamicDiscoveryDocument.cs
- Choices.cs
- XmlReflectionMember.cs
- DrawingContextWalker.cs
- ActionFrame.cs
- LogExtentCollection.cs
- SplitterEvent.cs
- SnapLine.cs
- AuthenticatingEventArgs.cs
- DbConnectionStringBuilder.cs
- ExpandedProjectionNode.cs
- AnimationClock.cs
- BamlResourceContent.cs
- ColumnProvider.cs
- MenuEventArgs.cs
- Hyperlink.cs
- SoapReflectionImporter.cs
- _IPv4Address.cs
- IPAddress.cs
- HashRepartitionEnumerator.cs
- LexicalChunk.cs
- DeflateStream.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- ParentUndoUnit.cs
- WriteTimeStream.cs
- UnsettableComboBox.cs
- CellCreator.cs
- Queue.cs
- ContextMenuService.cs
- RightsManagementResourceHelper.cs
- ConnectionStringsExpressionBuilder.cs
- HtmlInputSubmit.cs
- SlotInfo.cs
- TextWriterEngine.cs
- EditCommandColumn.cs
- PageContentCollection.cs
- ParentQuery.cs
- DiscoveryDocumentSerializer.cs
- ParameterBuilder.cs
- CompressedStack.cs
- ExpressionBindings.cs
- QueueProcessor.cs
- ResourcesGenerator.cs
- PreProcessor.cs
- ApplicationHost.cs
- DataGridCell.cs
- SourceFileBuildProvider.cs
- SurrogateSelector.cs
- PageStatePersister.cs
- CopyAction.cs
- PanelContainerDesigner.cs
- UTF8Encoding.cs
- LightweightCodeGenerator.cs
- EdmMember.cs
- PipelineComponent.cs
- DefinitionUpdate.cs
- ParseChildrenAsPropertiesAttribute.cs
- Thumb.cs
- MsmqInputChannelBase.cs
- DataGridViewRowCollection.cs
- URIFormatException.cs
- ColorConverter.cs
- SoapDocumentMethodAttribute.cs
- CompiledQuery.cs
- FlowDocumentFormatter.cs
- CodeSnippetCompileUnit.cs
- MemberMemberBinding.cs
- ProfileBuildProvider.cs
- BuildManager.cs
- ToolStripPanelSelectionBehavior.cs
- safemediahandle.cs
- Polyline.cs
- FormClosedEvent.cs
- TextOutput.cs
- ValueQuery.cs