Cannot Get Scrollbars on DataGrid to actually work...

CodeLiftsleep

Member
Joined
Mar 11, 2016
Messages
20
Programming Experience
3-5
The vertical and horizontal scrollbars are showing on my DataGrid, but they don't actually do anything when you click on them. They appear grayed out and do nothing. I have seen some code where I have to encapsulate the DataGrid in a Scrollbar viewer and/or ScrollBar but as of right now I have not been able to get any of the XAML to work properly with it...if anyone could lend me a hand on this it would be greatly appreciated, I am unsure what I am doing incorrectly...switching from WinForms to WPF has been mostly awesome, as there are a lot of things that are much faster and easier in WPF, but then I run into things like this that were handled automatically in WinForms(my datagrid always had both scrollbars enabled and was able to be sorted by any column automatically without me doing anything---neither of these is the case in WPF). I am mostly learning XAML/WPF on the fly and have figured out most things I have had questions on, including writing a custom Event Handler for a mouse button click on a text box because the normal one would fire anytime a button was pushed anywhere instead of just on the textbox, but this one has eluded me and I've spent many hours trying to resolve this unsuccessfully...

Here is my XAML:

VB.NET:
<Page x:Class="GenerationDraft"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:WPFGeneration"
      mc:Ignorable="d"
      d:DesignHeight="1600" d:DesignWidth="2400"
      Title="Generation: Draft Players">


    <Grid x:Name="DraftGenGrid" Height="Auto" Width="Auto" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Image x:Name="GoalLineStandPic" Source="JENK10.png" MaxHeight="1600" MaxWidth="2400" Opacity="0.4" Stretch="Fill" Grid.RowSpan="3" />
       
        <DataGrid x:Name="DraftGrid" HorizontalAlignment="Center"  ItemsSource="{Binding}" MaxHeight="300" MaxWidth="2400"  Grid.Row="2"/>
      
        <TextBlock x:Name="GenDraftText" FontSize="30" FontStyle="Normal" FontFamily="Times New Roman Bold" Text="Goal Line Stand College Draft Creator" Margin="5,5,0,0" Grid.RowSpan="3"></TextBlock>
        <Button x:Name="CreateDraft" Content="Create Draft Class" HorizontalAlignment="Left" Margin="10,140,0,0" Style="{DynamicResource SimpleButton}" VerticalAlignment="Top" Width="145" Height="50" Opacity="0.7">
            <Button.Background>
                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="#FFEEEEEE" Offset="0" />
                    <GradientStop Color="#FF1A21B4" Offset="1" />
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="OpenDB" Content="Choose DataBase To Open" HorizontalAlignment="Left" Margin="10,80,0,0" Style="{DynamicResource SimpleButton}" VerticalAlignment="Top" Width="145" Height="50" Opacity="0.7">
            <Button.Background>
                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="#FFEEEEEE" Offset="0" />
                    <GradientStop Color="#FF1A21B4" Offset="1" />
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <TextBox x:Name="CreateDraftTextBox" HorizontalAlignment="Left" Height="23" Margin="9,194,0,0" Style="{DynamicResource SimpleTextBox}" TextWrapping="Wrap" Text="Enter Num Players To Create" VerticalAlignment="Top" Width="186" Opacity="0.6" Background="#B54B79C6" IsReadOnly="False"
                 MouseDown="Button_MouseDown">
        </TextBox>


        <TextBlock x:Name="DepthPositions" HorizontalAlignment="Left" Width="140" Margin="9,237,0,0" RenderTransformOrigin="0.521,0.722"><Run Text="QB Depth:" /><LineBreak /><Run Text="RB Depth:" /><LineBreak /><Run Text="FB Depth:" /><LineBreak />
            <Run Text="WR Depth:" /><LineBreak /><Run Text="TE Depth:" /><LineBreak /><Run Text="OT Depth:" /><LineBreak /><Run Text="C Depth:" /><LineBreak /><Run Text="OG Depth:" /><LineBreak /><Run Text="DE Depth:" /><LineBreak /><Run Text="DT Depth:" />
            <LineBreak /><Run Text="OLB Depth:" /><LineBreak /><Run Text="ILB Depth:" /><LineBreak /><Run Text="CB Depth:" /><LineBreak /><Run Text="FS Depth:" /><LineBreak /><Run Text="SS Depth:" /><LineBreak /><Run Text="K Depth:" /><LineBreak /><Run Text="P Depth:" />
            <LineBreak /><Run /></TextBlock>
    </Grid>
</Page>
 

Latest posts

Back
Top