C
C#•12mo 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
FabiCrafter•12mo 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
FabiCrafter•12mo ago
No description
No description
No description
Dharmang
Dharmang•12mo ago
I think @Mimal99 can help you with that 😉 ...
FabiCrafter
FabiCrafter•12mo ago
Thanks, let's see what he's saying 🙂
Dharmang
Dharmang•12mo ago
Can you share the whole sample code?
FabiCrafter
FabiCrafter•12mo ago
Sure, one moment
FabiCrafter
FabiCrafter•12mo ago
It's just XAML code for the design, I'll add the C# code and all functions later
FabiCrafter
FabiCrafter•12mo ago
Or do you need more?
Dharmang
Dharmang•12mo ago
no just need this
FabiCrafter
FabiCrafter•12mo ago
alright
Dharmang
Dharmang•12mo ago
@FabiCrafter it seems the issue is with the custom scrollbar template
FabiCrafter
FabiCrafter•12mo ago
Okay, do you have any idea how to fix it? I have no clue why this happened
Dharmang
Dharmang•12mo 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
FabiCrafter•12mo ago
I've just tried that, but unfortunately ChatGPT 3.5 doesn't seem to have a solution for my problem
Dharmang
Dharmang•12mo ago
i am not much experienced with wpf but try this out. chatpgpt is giving half-a$$ results
Dharmang
Dharmang•12mo 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
FabiCrafter•12mo ago
Adding IsDirectionReversed="True" to my Track attribute fixed the issue. Thanks guys.
Dharmang
Dharmang•12mo 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