TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
prathap k
NA
85
6.5k
How to scroll the items in stack panel in WPF Using Buttons
May 2 2016 3:35 AM
Hi, all.
I have a requirement like I need to bind some buttons to stack panel and I need to put two buttons below if I click on Down button I need to show the items which are below the default came items like the same for up button also.
What I have tried:
I just bind items to stack panel programmatically.
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
Button[] Button = new Button[ds.Tables[0].Rows.Count];
try
{
Button[i] = new Button();
string id = ds.Tables[0].Rows[i][0].ToString();
string status = ds.Tables[0].Rows[i][1].ToString();
if (status == "Pending")
{
Button[i].Background = Brushes.Red;
}
if (status == "Cancelled")
{
Button[i].Background = Brushes.Orange;
}
if (status == "Completed")
{
Button[i].Background = Brushes.Green;
}
// string s1 = ds.Tables[0].Rows[i][1].ToString();
Button[i].Content = id;
Button[i].Tag = id;
Button[i].Click += btn_Click;
Button[i].Height = 41;
Button[i].Width = 120;
Button[i].Foreground = Brushes.White;
Button[i].FontWeight = FontWeights.Bold;
Button[i].FontStyle = FontStyles.Italic;
Button[i].FontSize = 14;
stackPanel1.Children.Add(Button[i]);
}
catch (Exception ex)
{
}
}
}
private void btnup_Click(object sender, RoutedEventArgs e)
{
//what should i do here
}
private void btndown_Click(object sender, RoutedEventArgs e)
{
//what should i do here
}
Reply
Answers (
1
)
Get the Value of WPF Listview rows
difference between name and x:name in xaml wpf??