Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Looking Ahead
>
Using PowerShell v2.0
How do I Combine the 2 WFP Approaches
Last Post 02 Apr 2009 12:41 PM by
PowerShell Jedi
. 2 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
PowerShell Jedi
Basic Member
Posts:410
02 Apr 2009 02:44 AM
OK, so I'd Like to use a Runspace for my WPF Like so....
# ------------------------------------------
# Create a runspace to run Hello World
$rs = [RunspaceFactory]::CreateRunspace()
$rs.ApartmentState, $rs.ThreadOptions = “STA”, “ReuseThread”
$rs.Open()
$psCmd = {Add-Type -AssemblyName PresentationCore,PresentationFramework,WindowsBase}.GetPowerShell()
$psCmd.Runspace = $rs
$psCmd.Invoke()
$psCmd.Commands.Clear()
$psCmd.AddScript({
$window = New-Object Windows.Window
$window.Title = “Hello World."
$window.Content = "PoSH is Cooool!”
$window.FontSize = '48'
$window.SizeToContent = “WidthAndHeight”
$window.add_MouseDoubleClick({$this.Close()})
$null = $window.ShowDialog()
}).BeginInvoke()
# ------------------------------------------
But I also want write my UI with Proper XAML Like this aproach...
# ------------------------------------------
Add-Type -AssemblyName presentationframework
Add-Type –assemblyName PresentationCore
Add-Type –assemblyName WindowsBase
[xml]$xaml = @'
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="This is a test" Height="300" Width="300">
Server 1
Button
'@
$reader=(New-Object Xml.XmlNodeReader $xaml)
$Form=[Windows.Markup.XamlReader]::Load( $reader )
$Form.ShowDialog() | out-null
# ------------------------------------------
So I guess my Question is how do I combine the 2 approaches. My reason for wanting to use the XAML approach is that's how Visual Studio 2008 Writes it and I feel you have more control over the UI that way.
As always I'm open to your comments Criticisms, am I taking the correct approach etc..
PoSH is a Automation Technology surfaced as a scripting language, not a "spice" ;-)
Marco Shaw (MVP)
Veteran Member
Posts:1647
02 Apr 2009 11:26 AM
Are you getting my direct emails to you?
I think Doug's post here provides the framework for this:
http://dougfinke.com/blog/index.php...nt-page-1/
Marco
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*Blog - http://marcoshaw.blogspot.com
PowerShell Jedi
Basic Member
Posts:410
02 Apr 2009 12:41 PM
AHHHH! I figured out my Problems!!!
XAML is Case Sensitive!!
Powershell isn't!!
When working with XAML you have to be aware of cAse!!
I hate problems like that!!!!!
PoSH is a Automation Technology surfaced as a scripting language, not a "spice" ;-)
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Looking Ahead
>
Using PowerShell v2.0
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2