C
C#•13mo ago
FabiCrafter

WPF ScrollViewer issues

Hello, I have the problem that the scrollviewer in C# (WPF) does not work properly. I haven't defined anything special, but the scrollviewer runs from bottom to top, i.e. with the content, which is exactly the opposite direction. I would be very grateful if someone could help me. My code:
18 Replies
FabiCrafter
FabiCrafterOP•13mo ago
<ScrollViewer VerticalScrollBarVisibility="Visible" Margin="10,10,10,10">
<ScrollViewer.Resources>
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
<Setter Property="Foreground" Value="DarkGray"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid>
<Track x:Name="PART_Track" Width="10">
<Track.Thumb>
<Thumb>
<Thumb.Template>
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle Fill="{TemplateBinding Background}" RadiusX="5" RadiusY="5"/>
</ControlTemplate>
</Thumb.Template>
<Thumb.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="DarkGray" Offset="0.0"/>
<GradientStop Color="Gray" Offset="0.5"/>
<GradientStop Color="DarkGray" Offset="1.0"/>
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ScrollViewer.Resources>
<ScrollViewer VerticalScrollBarVisibility="Visible" Margin="10,10,10,10">
<ScrollViewer.Resources>
<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
<Setter Property="Foreground" Value="DarkGray"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid>
<Track x:Name="PART_Track" Width="10">
<Track.Thumb>
<Thumb>
<Thumb.Template>
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle Fill="{TemplateBinding Background}" RadiusX="5" RadiusY="5"/>
</ControlTemplate>
</Thumb.Template>
<Thumb.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="DarkGray" Offset="0.0"/>
<GradientStop Color="Gray" Offset="0.5"/>
<GradientStop Color="DarkGray" Offset="1.0"/>
</LinearGradientBrush>
</Thumb.Background>
</Thumb>
</Track.Thumb>
</Track>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ScrollViewer.Resources>
FabiCrafter
FabiCrafterOP•13mo ago
No description
No description
No description
Dharmang
Dharmang•13mo ago
I think @Mimal99 can help you with that 😉 ...
FabiCrafter
FabiCrafterOP•13mo ago
Thanks, let's see what he's saying 🙂
Dharmang
Dharmang•13mo ago
Can you share the whole sample code?
FabiCrafter
FabiCrafterOP•13mo ago
Sure, one moment
FabiCrafter
FabiCrafterOP•13mo ago
It's just XAML code for the design, I'll add the C# code and all functions later
FabiCrafter
FabiCrafterOP•13mo ago
Or do you need more?
Dharmang
Dharmang•13mo ago
no just need this
FabiCrafter
FabiCrafterOP•13mo ago
alright
Dharmang
Dharmang•13mo ago
@FabiCrafter it seems the issue is with the custom scrollbar template
FabiCrafter
FabiCrafterOP•13mo ago
Okay, do you have any idea how to fix it? I have no clue why this happened
Dharmang
Dharmang•13mo ago
... 😄 i just know dotnet web api's but when i commented out that code it is working as expected. maybe try getting the code from chatgpt. i am doing that rn
FabiCrafter
FabiCrafterOP•13mo ago
I've just tried that, but unfortunately ChatGPT 3.5 doesn't seem to have a solution for my problem
Dharmang
Dharmang•13mo ago
i am not much experienced with wpf but try this out. chatpgpt is giving half-a$$ results
Dharmang
Dharmang•13mo ago
GitHub
WPF-Custom-Scrollbar/Source/MainWindow.xaml at master · CSharpDesig...
How to design a Custom Scrollbar in WPF. Contribute to CSharpDesignPro/WPF-Custom-Scrollbar development by creating an account on GitHub.
FabiCrafter
FabiCrafterOP•13mo ago
Adding IsDirectionReversed="True" to my Track attribute fixed the issue. Thanks guys.
Dharmang
Dharmang•13mo ago
when i pasted i was getting errors.. and didnt know how to solve it lol
Want results from more Discord servers?
Add your server