を に追加しようとしてSystem.Windows.Controls.ScrollViewer
いますがSystem.Windows.Forms.TabPage
、関数Add(ScrollViewer)
が無効です。
XAMLではなく、組み込みのScrollViewerを追加する方法はありますかTabPage
。
ありがとう。
を に追加しようとしてSystem.Windows.Controls.ScrollViewer
いますがSystem.Windows.Forms.TabPage
、関数Add(ScrollViewer)
が無効です。
XAMLではなく、組み込みのScrollViewerを追加する方法はありますかTabPage
。
ありがとう。
これを WPF としてタグ付けしたので、フォームへの参照が間違っているのではないでしょうか?
タブ内のページの例を次に示します。これは、ツールバーが上部にあり、ステータス バーが下部にあり (MainWindow のステータス バーではありません...)、中央のコンテンツがスクロールできるようにするためのアイデアでした。 .
Dim vScrollViewer As New ScrollViewer
Dim vSP As New StackPanel
With vSP
.HorizontalAlignment = Windows.HorizontalAlignment.Stretch
.VerticalAlignment = Windows.VerticalAlignment.Stretch
End With
Dim vInnerGrid As New Grid
vScrollViewer.Content = vSP
vSP.Children.Add(vInnerGrid)
vScollViewer は、他のコントロール (3 行グリッドの中央など) に追加できます。
フルイベント
Private Sub Website_WebPage_Page_Initialized(sender As Object, e As System.EventArgs) Handles Me.Initialized
Try
Dim vScrollViewer As New ScrollViewer
Dim vSP As New StackPanel
With vSP
.HorizontalAlignment = Windows.HorizontalAlignment.Stretch
.VerticalAlignment = Windows.VerticalAlignment.Stretch
End With
Dim vInnerGrid As New Grid
vScrollViewer.Content = vSP
vSP.Children.Add(vInnerGrid)
Dim Col1 As New ColumnDefinition
With Col1
.Width = New GridLength(120)
End With
Dim Col2 As New ColumnDefinition
With Col2
.Width = New GridLength(200, GridUnitType.Star)
End With
With Website_WebPage_Grid
.Background = New SolidColorBrush(Colors.White)
End With
With vInnerGrid
.ColumnDefinitions.Add(Col1)
.ColumnDefinitions.Add(Col2)
End With
For i As Integer = 0 To 11 '
Dim vRow As New RowDefinition
With vRow
If i = 11 Then
.Height = New GridLength(200, GridUnitType.Star)
Else
.Height = New GridLength(35)
End If
End With
vInnerGrid.RowDefinitions.Add(vRow)
Next
Dim UpperRow As New RowDefinition
With UpperRow
.Height = New GridLength(35)
End With
Dim MiddleRow As New RowDefinition
With MiddleRow
.Height = New GridLength(200, GridUnitType.Star)
End With
Dim BottomRow As New RowDefinition
With BottomRow
.Height = New GridLength(35)
End With
With Website_WebPage_Grid
.RowDefinitions.Add(UpperRow)
.RowDefinitions.Add(MiddleRow)
.RowDefinitions.Add(BottomRow)
End With
Dim vToolBar As New ToolBar
With vToolBar
.Height = 35
End With
Grid.SetRow(vToolBar, 0)
Website_WebPage_Grid.Children.Add(vToolBar)
Dim EditButton As New Button
If NewRecord = False Then
With EditButton
.Content = ReturnToolBarImage("Edit.png")
.ToolTip = "Edit the record"
.Name = "WebsiteWebPage_EditButton"
End With
RegisterControl(Website_WebPage_Grid, EditButton, EditButton.Name.ToString)
vToolBar.Items.Add(EditButton)
vToolBar.Items.Add(TS_Separator)
End If
Dim SaveUpdateButton As New Button
With SaveUpdateButton
.Name = "WebsiteWebPage_SaveUpdateButton"
If NewRecord = True Then
.Content = ReturnToolBarImage("Record_Insert.png")
.ToolTip = "Save the record"
Else
.Content = ReturnToolBarImageGrey("Record_Update.png")
.ToolTip = "Update the record"
.IsEnabled = False
End If
End With
RegisterControl(Website_WebPage_Grid, SaveUpdateButton, SaveUpdateButton.Name.ToString)
vToolBar.Items.Add(SaveUpdateButton)
vToolBar.Items.Add(TS_Separator)
Dim OutPutLB As New Label
With OutPutLB
.Name = "WebsiteAdministrator_OutputLB"
.HorizontalAlignment = Windows.HorizontalAlignment.Right
.VerticalAlignment = Windows.VerticalAlignment.Center
.FontSize = 10
End With
RegisterControl(Website_WebPage_Grid, OutPutLB, OutPutLB.Name.ToString)
Grid.SetColumnSpan(OutPutLB, 2)
Grid.SetRow(OutPutLB, 0)
vInnerGrid.Children.Add(OutPutLB)
Dim vName As String = "WebsiteAdministrator_"
For i As Integer = 1 To 7
Dim vLabel As New Label
With vLabel
.FontSize = 10
.VerticalAlignment = Windows.VerticalAlignment.Center
.HorizontalAlignment = Windows.HorizontalAlignment.Left
End With
Dim vTB As New CustomControl.TBx
With vTB
.IsNewRecord = NewRecord
'.Width = 200
End With
Select Case i
Case 1
vLabel.Content = "Page Name"
With vTB
.Width = 200
.Name = vName & "PageNameTB"
End With
Case 2
vLabel.Content = "Meta Description"
With vTB
.Width = 600
.Name = vName & "MetaDescriptionTB"
End With
Case 3
vLabel.Content = "Title"
With vTB
.Width = 400
.Name = vName & "TitleTB"
End With
Case 4
vLabel.Content = "Navigate URL"
With vTB
.Width = 400
.Name = vName & "NavigateURLTB"
End With
Case 5
vLabel.Content = "Menu Text"
With vTB
.Width = 200
.Name = vName & "MenuTextTB"
End With
Case 6
vLabel.Content = "Menu ToolTip"
With vTB
.Width = 400
.Name = vName & "MenuToolTipTB"
End With
Case 7
vLabel.Content = "Menu Position"
With vTB
.Width = 100
.Name = vName & "MenuPositionTB"
End With
End Select
Grid.SetColumn(vLabel, 0)
Grid.SetRow(vLabel, i)
Grid.SetColumn(vTB, 1)
Grid.SetRow(vTB, i)
vInnerGrid.Children.Add(vLabel)
vInnerGrid.Children.Add(vTB)
Next
Grid.SetRow(vScrollViewer, 1)
Website_WebPage_Grid.Children.Add(vScrollViewer)
Dim DP As DockPanel = PageStatusBarDP(Website_WebPage_Grid)
Grid.SetRow(DP, 2)
Grid.SetColumnSpan(DP, 2)
Website_WebPage_Grid.Children.Add(DP)
Catch ex As Exception
EmailError(ex)
End Try
End Sub