LinearGradientBrush to VB

  • Modern UI

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Nofear23m.

    LinearGradientBrush to VB

    Hallo,

    Kann jemand mir bitte helfen ein stück XAML Code in VB.Net zu übersetzen.

    XAML Code

    Quellcode

    1. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    2. <GradientStop Color="#FF464646" Offset="0.243"/>
    3. <GradientStop Color="White" Offset="1"/>
    4. </LinearGradientBrush>


    Im Voraus Danke
    XAML zu VB? Du meinst sicher etwas äquivalentes in WinForms?

    VB.NET-Quellcode

    1. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    2. Dim blend As New Blend()
    3. Using lgb As New LinearGradientBrush(ClientRectangle, Color.FromArgb(70, 70, 70), Color.White, 90)
    4. blend.Factors = {0.0F, 0.0F, 1.0F}
    5. blend.Positions = {0.0F, 0.243F, 1.0F}
    6. lgb.Blend = blend
    7. e.Graphics.FillRectangle(lgb, ClientRectangle)
    8. End Using
    9. End Sub

    Cloud Computer? Nein Danke! Das ist nur ein weiterer Schritt zur totalen Überwachung.
    „Wer die Freiheit aufgibt, um Sicherheit zu gewinnen, wird am Ende beides verlieren.“
    Benjamin Franklin
    Hallo Nolde,



    Danke für deine
    Antwort.

    Das war nicht für
    Windows Forms aber für UWP gedacht. Trotzdem vielen Dank.

    Ich habe es gelöst
    mit folgendes:

    VB.NET-Quellcode

    1. Dim gradientBrush As LinearGradientBrush = New LinearGradientBrush
    2. gradientBrush.StartPoint = New Point(0.5, 0)
    3. gradientBrush.EndPoint = New Point(0.5, 1)
    4. Dim gradientStopStart As GradientStop = New GradientStop
    5. gradientStopStart.Color = Color.FromArgb(255, 56, 56, 56) '(255, 70, 70, 70)
    6. gradientStopStart.Offset = 0.243
    7. Dim gradientStopEnd As GradientStop = New GradientStop
    8. gradientStopEnd.Color = Color.FromArgb(255, 255, 255, 255)
    9. gradientStopEnd.Offset = 1
    10. gradientBrush.GradientStops.Add(gradientStopStart)
    11. gradientBrush.GradientStops.Add(gradientStopEnd)
    OK

    Das gehts aber weit einfacher.

    Folgendes:

    XML-Quellcode

    1. Dim gradientBrush = New LinearGradientBrush(Color.FromArgb(255, 56, 56, 56), Color.FromArgb(255, 255, 255, 255), 90)

    macht genau das selbe!!!

    Grüße
    Sascha
    If _work = worktype.hard Then Me.Drink(Coffee)
    Seht euch auch meine Tutorialreihe <WPF Lernen/> an oder abonniert meinen YouTube Kanal.

    ## Bitte markiere einen Thread als "Erledigt" wenn deine Frage beantwortet wurde. ##