Click here to Skip to main content
15,909,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new to WPF. I need a binding navigator to navigate through records in my datagrid. How to do it. I couldn't find a proper tutorial anywhere

What I have tried:

HTML
<pre>StackPanel x:Name="bindingNav"  Orientation="Horizontal" Margin="2,2,221.667,0" Height="29" VerticalAlignment="Top">
                <Button Name="btnFirst" Content="|◄" Width="30" />
                <Button Name="btnPrev" Content="◄" Width="30" />
                <TextBox x:Name="txtdisplay" HorizontalAlignment="Left" Height="36" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="71" />
                <TextBox x:Name="txtcount" HorizontalAlignment="Left" Height="36" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="47"/>
                <Button Name="btnNext" Content="►" Width="30"/>
                <Button Name="btnLast" Content="►| " Width="30"/>
                <Button Name="btnAddnew" Content="+" Width="30"/>
                <Button Name="btnrecordDelete" Content="X" Width="30"  />
                </StackPanel>

I tried creating with buttons in a stackpanel. But I couldn't know how to bind to datagrid.
Posted
Updated 22-Feb-19 4:06am

1 solution

"Navigating" in a datagrid (via buttons) consists of changing the "selected index".

A "navigator" is typically associated with a "form", because it has no "built-in" navigation, while a datagrid DOES.

Which begs the question of why have buttons when one can already click and / or scroll to navigate (more efficiently)?

And have you thought of "sorted" columns and how a "navigator" would deal with that?
 
Share this answer
 
Comments
Priya Karthish 22-Feb-19 13:45pm    
I am in the process of converting a project from vb to WPF C#.Net. They wanted the navigation button in the Windows. I was managed to find a solution using datagrid.SelectedIndex.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900