Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

adding wpf external on powershell

$
0
0

Hi Team,

I am creating an application for my work, but the only resources that I got is the built in powershell ISE from my desktop. I was able to do some applications for my co-leagues @ work using powershell + WPF. Now I am planning to create new application but this time I want to use EXTERNAL FILE for my <resourcedictionary>. But I spent a month (honestly) figuring out how to do it but I got none. I do believe powershell + WPF can do a Slick app. Please help me how to make it possible.

 

Here is my code #####

#build the GUI

Clear-host

cd "D:\powershell\Lesson\metro\"

Add-Type -AssemblyName PresentationCore,PresentationFramework,WindowsBase,system.windows.forms

[xml]$xaml = @"

<Window

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    WindowStartupLocation="CenterScreen" Name="Main"

    Width="800" Height="700" ShowInTaskbar="True">

        <Window.Resources>

                            <ResourceDictionary Source="sample.xaml" />     

        </Window.Resources>

</Window>

"@

$reader = (New-Object System.Xml.XmlNodeReader $xaml)

$Window = [Windows.Markup.XamlReader]::Load($reader)

$Window.ShowDialog()

Here is the error ###############################################

Exception calling "Load" with "1" argument(s): "'sample.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'. Cannot locate resource 'samp

le.xaml'.  Error at object 'System.Windows.ResourceDictionary'."

At D:\powershell\Lesson\metro\Basic_WPF.ps1:20 char:44

+ $Window = [Windows.Markup.XamlReader]::Load <<<< ($reader)

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : DotNetMethodException

I hope someone can help about this. Thanks Team.

Viewing all articles
Browse latest Browse all 6937

Trending Articles