WPF學習日誌 ~ DockPanel ~

摘要:WPF學習日誌 ~ DockPanel ~

打鐵要趁熱,下面這篇我們繼續看看DockPanel的部分,從名稱上可以看出這跟之前VS2005我們設定控制項的Dock屬性的感覺滿像的,沒錯,大致上是這樣的,下面我們看看測試的程式碼吧



    Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        dp = New DockPanel
        Me.Title = "DockPanel Test"
        Me.Content = dp
        For z As Integer = 0 To 3
            Dim btn As New Button
            btn.Name = "Button" & z
            btn.Content = "Button_" & z
            DockPanel.SetDock(btn, z)
            dp.Children.Add(btn)
            ''設定最後加入的元素是否要填滿剩下的空間
            dp.LastChildFill = False
        Next
    End Sub