none
Disable WPF Controls in Powershell RRS feed

  • Frage


  • Die Dialoge sehen mit WPF besser aus,
    beim Umstellen eines Dialoges fehlt mir jedoch die
    Möglichkeit z.B. einen Button auf Disable zu setzen,
    wenn der Context nicht passt.

    Wie ist die neue Philosophie bei Dialogen,
    wenn dies so schwer fällt,
    oder geht es doch?

    Ich verwende Powershell mit dem ShowUi Modul.

    Danke für euren Rat

    Erhy

    Samstag, 1. Februar 2014 15:33

Antworten

  • nun ist es mir doch gelungen.
    Man muss bloß mit New- deklarieren

    Erhy

    Import-Module ShowUi
    $zweiErge = -1
    Write-Host  "start"
    
    New-Window  -Name MainWindow -Width 200 -Height 320 -title 'Minutes till hibernate' `
                -ResizeMode CanMinimize -Background Pink -Top 0 -Left 0 {
        New-StackPanel -Margin 10 -Background Pink {
            New-TextBox -Text "minutes`ntill hibernate" -IsReadOnly $True `
                -Background Pink -BorderThickness 0 -FontFamily Arial -FontSize 22.0 `
                -HorizontalContentAlignment Center `
                -TextWrapping Wrap `
                -On_GotFocus {
                    $TxtForMinutes.Focus()
                }
            New-Separator -Height 1  -Background Pink
            New-Label "Minutes:" -FontFamily Consolas -FontSize 13.0 -FontWeight Bold
            New-TextBox -Name TxtForMinutes -Text 60 `
                        -FontFamily Consolas -FontSize 24.0 `
                        -HorizontalContentAlignment Right -FontWeight Bold
            New-Separator -Height 1  -Background Pink
            New-Label "Time:" -FontFamily Consolas -FontSize 13.0 -FontWeight Bold
            New-TextBox -Name TxtForTime -Text '--:--' `
                -FontFamily Consolas -FontSize 24.0 `
                -HorizontalContentAlignment Right -FontWeight Bold
            New-Separator -Height 15  -Background Pink
            New-StackPanel -Background Pink -Orientation Horizontal -HorizontalAlignment Center {
                New-Button "OK" -name btnOK -Margin 5 -Width 80 -Height 32 -FontFamily Consolas -FontSize 22.0 -FontWeight Bold 
                New-Button "Cancel" -Margin 5 -Width 80 -Height 32 -FontFamily Consolas -FontSize 22.0 -TabIndex 1 `
                            -On_Click { 
                                $global:zweiErge = 77787
                                Close-Control
                            }                    
                } -On_Loaded {
                        Write-Host  "2nd Panel"
                        $btnOK.IsEnabled = $False
                    }          # end of second StackPanel
            } # end of first StackPanel
    } -show
    $zweiErge   
    

    Samstag, 1. Februar 2014 17:24