Giter Site home page Giter Site logo

metrohamburgermenu_v3's People

Contributors

dev4sys avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

metrohamburgermenu_v3's Issues

ItemsSource cannot be found

Hello @dev4sys,

First of all I would like to say thank you for the awesome work you're doing!
I've been looking around a lot to help me build a WPF GUI for my PowerShell script, and found your blog posts the most helpfull.

That being said, you have to know I'm completely new to WPF so sorry for any stupid questions I'm asking.

I'm trying to combine the DataGrid used in your PsCustomDialog (https://github.com/dev4sys/PsCustomDialog) with this HamburgerMenu and show the DNS records in our domain.
What I have done to get this working is I replaced the code from views\Home.xaml with below code:

<Grid
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

	
	<Grid.Resources>
	    <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\resources\Icons.xaml" />
	        </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Grid.Resources>
    
    <Grid>
        <StackPanel HorizontalAlignment="Center">

			<!-- CONTAINER -->
			<StackPanel Margin="10,10,10,10" HorizontalAlignment="Center" VerticalAlignment="Top" Orientation="Vertical">	

                <DataGrid x:Name="DNSGrid" AutoGenerateColumns="False" Margin="33,0,0,0"
                    GridLinesVisibility="All" HorizontalGridLinesBrush="#FFD4D4D4"  VerticalGridLinesBrush="#FFD4D4D4" 
                    OverridesDefaultStyle="True" CanUserAddRows="False">
                    <DataGrid.Columns>

                        <DataGridTextColumn Binding="{Binding DNSName}" Header="Name" IsReadOnly="True" Width="auto"/>
                        <DataGridTextColumn Binding="{Binding DNSType}" Header="Type" IsReadOnly="True" Width="auto"/>
                        <DataGridTextColumn Binding="{Binding DNSData}" Header="Data" IsReadOnly="True" Width="auto"/>
                        <DataGridTextColumn Binding="{Binding DNSTimestamp}" Header="Timestamp" IsReadOnly="True" Width="auto"/>

                        <DataGridTemplateColumn>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">

                                        <Button x:Name="View"  Background="#FF44AFE3" Style="{DynamicResource MetroCircleButtonStyle}" 
                                            Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch" 
                                            VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center" 
                                            BorderThickness="0" Margin="0,0,0,0">
                                            <Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white">
                                                <Rectangle.OpacityMask>
                                                    <VisualBrush  Stretch="Fill" Visual="{StaticResource appbar_magnify}"/>
                                                </Rectangle.OpacityMask>
                                            </Rectangle>
                                        </Button>

                                        <Button x:Name="Edit"  Background="#198C19" Style="{DynamicResource MetroCircleButtonStyle}" 
                                            Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch" 
                                            VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center" 
                                            BorderThickness="0" Margin="0,0,0,0">
                                            <Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white">
                                                <Rectangle.OpacityMask>
                                                    <VisualBrush  Stretch="Fill" Visual="{StaticResource appbar_edit}"/>
                                                </Rectangle.OpacityMask>
                                            </Rectangle>
                                        </Button>

                                        <Button x:Name="Delete"  Background="#FFA500" Style="{DynamicResource MetroCircleButtonStyle}" 
                                            Height="28" Width="28" Cursor="Hand" HorizontalContentAlignment="Stretch" 
                                            VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center" 
                                            BorderThickness="0" Margin="0,0,0,0">
                                            <Rectangle Width="10" Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="white" >
                                                <Rectangle.OpacityMask>
                                                    <VisualBrush  Stretch="Fill" Visual="{StaticResource appbar_close}"/>
                                                </Rectangle.OpacityMask>
                                            </Rectangle>
                                        </Button>

                                    </StackPanel>

                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>


                    </DataGrid.Columns>
                </DataGrid>

			</StackPanel>

			
		</StackPanel>
    </Grid>
	
</Grid>

The PowerShell command I'm using to get the DNS info is:
$DNSData = Get-DnsServerResourceRecord -ComputerName HOSTNAME -ZoneName domain.com | Select-Object Hostname,RecordType,Timestamp,RecordData

In my Main.ps1 I have below code:

$DNSGrid                        = $HomeXaml.FindName("DNSGrid") | Out-Null

$Script:observableCollection    = [System.Collections.ObjectModel.ObservableCollection[Object]]::new()
foreach ( $DNSRecord IN $DNSData ) {
    $objArray                       = New-Object PSObject
    $objArray | Add-Member -type NoteProperty -name DNSName -value $DNSRecord.Hostname
    $objArray | Add-Member -type NoteProperty -name DNSType -value $DNSRecord.RecordType
    $objArray | Add-Member -type NoteProperty -name DNSData -value $DNSRecord.RecordData
    $objArray | Add-Member -type NoteProperty -name DNSTimestamp -value $DNSRecord.Timestamp
    $Script:observableCollection.Add($objArray) | Out-Null
}

# Add data to the datagrid
$DNSGrid.ItemsSource            = $Script:observableCollection

(You see $DNSGrid = $HomeXaml.FindName("DNSGrid") | Out-Null in the first line, when I remove | Out-Null from that line I see a lot of text in my PS window and PS then crashes (going to fast to see what is being thrown in the PS window))

But when I start the script, I get below error in my PS window:

The property 'ItemsSource' cannot be found on this object. Verify that the property exists and can be set.
At C:\PATH_TO_SCRIPT\Scripts\GUI Scripts\DNSManager\Main.ps1:190 char:1
+ $DNSGrid.ItemsSource            = $Script:observableCollection
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

When I replace my foreach with your sample code like below, I'm getting the same error.

$objArray = New-Object PSObject
$objArray | Add-Member -type NoteProperty -name ComputerName -value "Computer_03"
$objArray | Add-Member -type NoteProperty -name IP_Adress -value "192.168.0.0"
$objArray | Add-Member -type NoteProperty -name Domain -value "Domain0"
$objArray | Add-Member -type NoteProperty -name Patch -value $true
$script:observableCollection.Add($objArray) | Out-Null

Do you have any idea what I'm doing wrong here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.