我在 ScrollViewer 中使用 LibVLCSharp 的 VideoView,ScrollViewer 位于 UserControl 内。当我滚动时,VideoView(或其中的控件)保持在同一位置,而其他所有内容都在移动...
我在 ScrollViewer 中使用 LibVLCSharp 的 VideoView,ScrollViewer 位于 UserControl 内。当我滚动时,VideoView(或其中的控件)会停留在同一位置,而其他所有内容都会移动。但是,如果您拖动窗口,它就会停留在原处。尝试谷歌搜索了很长时间,但找不到任何解决方案。
YouTube 上的 视频
这是 xaml 代码
`<UserControl xmlns="https://github.com/avaloniaui"
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"
xmlns:vm="using:LauncherSIPAvalonia.ViewModels"
xmlns:views="using:LauncherSIPAvalonia.Views"
xmlns:lvs="using:LibVLCSharp.Avalonia"
mc:Ignorable="d"
x:Class="LauncherSIPAvalonia.Views.LearnMore.LearnMoreView">
<ScrollViewer>
<StackPanel Margin="40"
Orientation="Vertical">
<Grid HorizontalAlignment="Left"
ColumnDefinitions="1.2* *">
<Grid RowDefinitions="3* *"
Grid.Column="0">
<Border CornerRadius="6"
Width="640"
Height="360">
<lvs:VideoView x:Name="Video"
Width="640"
Height="360"
IsVisible="False">
<Grid RowDefinitions="8* *"
x:Name="VideoViewInnerControls"
IsVisible="False">
<Border Grid.Row="1"
Background="rgba(0, 0, 0, 0.7)"/>
<Grid Grid.Row="1"
RowDefinitions="* 2*">
<Rectangle Fill="#7F1D1D"
x:Name="ProgressBarBackground"
Grid.Row="0"
PointerPressed="ProgressBar_PointerPressed"/>
<Rectangle x:Name="ProgressBar"
Fill="#B91C1C"
HorizontalAlignment="Left"
MaxWidth="640"
Grid.Row="0"
PointerPressed="ProgressBar_PointerPressed"/>
<Grid Grid.Row="1"
ColumnDefinitions="* * * 15*">
<Button Grid.Column="0"
Width="32"
Height="32"
Classes="Toolbar"
Click="PlayControl_Click">
<Image x:Name="PlayControl"
Width="32"
Height="32"/>
</Button>
<Button Grid.Column="1"
Width="32"
Height="32"
Classes="Toolbar"
Click="VolumeControl_Click">
<Image Source="/Assets/volume.png"
x:Name="VolumeControl"
Width="16"
Height="16"/>
</Button>
</Grid>
</Grid>
</Grid>
</lvs:VideoView>
</Border>
<Image x:Name="ScreenshotImage"
IsVisible="True"
Stretch="UniformToFill"
Width="640"
Height="360"/>
<Grid Grid.Row="1"
Height="84"
Width="640"
Margin="0 15"
HorizontalAlignment="Stretch">
<Border Background="rgba(0, 0, 0, 0.3)"
CornerRadius="0 0 6 6"/>
<ScrollViewer HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Disabled"
HorizontalAlignment="Stretch">
<UniformGrid x:Name="ListOfMedia"
Rows="1"
HorizontalAlignment="Stretch">
</UniformGrid>
</ScrollViewer>
</Grid>
</Grid>
<Grid Margin="20 0"
Grid.Column="1"
RowDefinitions="2.84* *">
<StackPanel Grid.Row="0"
Orientation="Vertical"
Spacing="10">
<TextBlock x:Name="TitleBlock"
FontSize="24"
LineHeight="32"
FontWeight="SemiBold"
TextWrapping="Wrap"/>
<TextBlock x:Name="DescriptionBlock"
FontSize="16"
LineHeight="28"
FontWeight="Regular"
TextWrapping="Wrap"/>
</StackPanel>
<Grid Grid.Row="1"
RowDefinitions="* 2*">
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="10">
<TextBlock x:Name="PriceBlock"
HorizontalAlignment="Right"
FontSize="28"
FontWeight="SemiBold"/>
<TextBlock x:Name="OriginalPriceBlock"
HorizontalAlignment="Right"
FontSize="28"
FontWeight="SemiBold"
TextDecorations="Strikethrough"
Foreground="#9CA3AF"
IsVisible="False"/>
</StackPanel>
</Grid>
<Button Grid.Row="1"
HorizontalAlignment="Stretch"
Height="50"
Click="Interact_Click"
Name="ActionButton">
<TextBlock FontSize="18"
FontWeight="SemiBold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Name="ActionLabel">
Купить
</TextBlock>
</Button>
</Grid>
</Grid>
</Grid>
<StackPanel Spacing="6">
<TextBlock x:Name="TagsBlock"
FontSize="14">
<Run Text="Теги:" FontWeight="Bold"/>
</TextBlock>
<StackPanel Orientation="Horizontal"
Spacing="6">
<StackPanel Orientation="Vertical"
Name="SystemRequirementsItems"
Spacing="6">
<TextBlock FontWeight="Bold"
Padding=" 0 0 0 4"
FontSize="14">
Системные требования:
</TextBlock>
</StackPanel>
<StackPanel Orientation="Vertical"
Name="MinimalSystemRequirements"
Width="300"
Spacing="6">
<TextBlock FontWeight="SemiBold"
Padding=" 0 0 0 4"
FontSize="14">
Минимальные
</TextBlock>
</StackPanel>
<StackPanel Orientation="Vertical"
Name="RecommendedSystemRequirements"
Width="300"
Spacing="6">
<TextBlock FontWeight="SemiBold"
Padding=" 0 0 0 4"
FontSize="14">
Рекомендуемые
</TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>`
尝试调用任何应该重新渲染的方法(Render()),每次需要修复时尝试将窗口向上移动 1 个像素,然后向下移动 1 个像素,但这看起来并不是滚动的好解决方案......