Skip to content

Latest commit

 

History

History
47 lines (39 loc) · 1.15 KB

File metadata and controls

47 lines (39 loc) · 1.15 KB
pid 1017
author Joel Bennett
title Set-AttachedProperty
date 2009-04-12 09:13:17 -0700
format posh
parent 0

Set-AttachedProperty

A piece that's missing from PoshCode 0.01

#function Set-AttachedProperty {
[CmdletBinding()]
PARAM(
   [Parameter(Position=0,Mandatory=$true)
   [System.Windows.DependencyProperty]
   $Property
,
   [Parameter(Mandatory=$true,ValueFromPipeline=$true)
   $Element
)
DYNAMICPARAM {
   $paramDictionary = new-object System.Management.Automation.RuntimeDefinedParameterDictionary
   $Param1 = new-object System.Management.Automation.RuntimeDefinedParameter
   $Param1.Name = "Value"
   # $Param1.Attributes.Add( (New-ParameterAttribute -Position 1) )
   $Param1.Attributes.Add( (New-Object System.Management.Automation.ParameterAttribute -Property @{ Position = 1 }) )
   $Param1.ParameterType = $Property.PropertyType
           
   $paramDictionary.Add("Value", $Param1)
   
   return $paramDictionary
}
PROCESS {
   $Element.SetValue($Property, $Param1.Value)
   $Element
}
#}
#New-Alias sap Set-AttachedProperty