feat: WPF控件-8-ScrollViewer
This commit is contained in:
parent
ad73569c67
commit
49a9bb8aab
|
@ -0,0 +1,9 @@
|
||||||
|
<Application x:Class="WPF控件_8_ScrollViewer.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:WPF控件_8_ScrollViewer"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF控件_8_ScrollViewer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
|
@ -0,0 +1,52 @@
|
||||||
|
<Window x:Class="WPF控件_8_ScrollViewer.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="100" Width="800">
|
||||||
|
|
||||||
|
<!-- VerticalScrollBarVisibility 枚举值来自: ScrollBarVisibility
|
||||||
|
Disabled:不显示滚动条
|
||||||
|
Auto
|
||||||
|
Hidden:会隐藏滚动条,但是会滚动只是看不到滚动条
|
||||||
|
Visible
|
||||||
|
-->
|
||||||
|
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button Name="LineUpButton" Margin="3" Click="LineUpButton_OnClick">LineUpButton</Button>
|
||||||
|
<Button Name="LineDownButton" Margin="3" Click="LineDownButton_OnClick">LineDownButton</Button>
|
||||||
|
<Button Name="PageUpButton" Margin="3" Click="PageUpButton_OnClick">PageUpButton</Button>
|
||||||
|
<Button Name="PageLeftButton" Margin="3" Click="PageLeftButton_OnClick">PageLeftButton</Button>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- CanContentScroll="True" 每次滚动会滚动到每个元素开头 -->
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto" Name="MyScrollViewer" CanContentScroll="True" Height="50">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="30" />
|
||||||
|
<RowDefinition Height="30" />
|
||||||
|
<RowDefinition Height="30" />
|
||||||
|
<RowDefinition Height="30" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" Margin="3" VerticalAlignment="Center">Home: </Label>
|
||||||
|
<TextBox Grid.Row="1" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
|
||||||
|
<Button Grid.Row="1" Grid.Column="2" Margin="3" Padding="2" Content="000" />
|
||||||
|
|
||||||
|
<Label Grid.Row="2" Grid.Column="0" Margin="3" VerticalAlignment="Center">搜索:</Label>
|
||||||
|
<TextBox Grid.Row="2" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
|
||||||
|
<Button Grid.Row="2" Grid.Column="2" Margin="3" Padding="2">预览</Button>
|
||||||
|
|
||||||
|
<Label Grid.Row="3" Grid.Column="0" Margin="3" VerticalAlignment="Center">看看:</Label>
|
||||||
|
<TextBox Grid.Row="3" Grid.Column="1" Margin="3" Height="Auto" VerticalAlignment="Center" />
|
||||||
|
<Button Grid.Row="3" Grid.Column="2" Margin="3" Padding="2">预览</Button>
|
||||||
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF控件_8_ScrollViewer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LineUpButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MyScrollViewer.LineUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LineDownButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MyScrollViewer.LineDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PageUpButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MyScrollViewer.PageUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PageLeftButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MyScrollViewer.PageLeft();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>WPF控件_8_ScrollViewer</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-6-工具提示",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-7-Popup", "WPF控件-7-Popup\WPF控件-7-Popup.csproj", "{1C272D2C-BAC3-4D94-9491-E05B688B9A98}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-7-Popup", "WPF控件-7-Popup\WPF控件-7-Popup.csproj", "{1C272D2C-BAC3-4D94-9491-E05B688B9A98}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-8-ScrollViewer", "WPF控件-8-ScrollViewer\WPF控件-8-ScrollViewer.csproj", "{84E26482-499C-412E-B43E-931BD0C0E983}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -48,5 +50,9 @@ Global
|
||||||
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1C272D2C-BAC3-4D94-9491-E05B688B9A98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{84E26482-499C-412E-B43E-931BD0C0E983}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{84E26482-499C-412E-B43E-931BD0C0E983}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{84E26482-499C-412E-B43E-931BD0C0E983}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{84E26482-499C-412E-B43E-931BD0C0E983}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue