add custom clickable buttons
I am developing an app for win phone 7. In that I need to add clickable buttons(not specific number) into a grid dynamically.and navigate the page with some information to other page.
can any body help me please....
private void buildThumbs(Grid gridThumb, int p) {
int n; if (p % 3 == 0) n = p / 3; else n = (p / 3) + 1; GridLength height = new GridLength(100); for (int i = 0; i < n; i++) { 开发者_如何学C RowDefinition rowDef = new RowDefinition(); rowDef.MinHeight = 100; gridThumb.RowDefinitions.Add(rowDef); } MovieThumb[,] thumb = new MovieThumb[n, 3]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { Image ni=new Image(); ImageSourceConverter ims = new ImageSourceConverter(); ni.SetValue(Image.SourceProperty ,ims.ConvertFromString( "/Images/book1.png")); thumb[i, j].SetValue(Grid.ColumnProperty, j); thumb[i,j].SetValue(Grid.RowProperty,i); thumb.Click += new RoutedEventHandler(thumb_click("sandy")); thumb[i, j].CoverImage = ni; thumb[i, j].Loading = "Loading"; thumb[i, j].progress = false; gridThumb.Children.Add(thumb); } }
}
I am not quite sure if I understand your problem, but if you want to set the Column and Row number for your dynamically created buttons, you may do so with Grid.SetColumn(buttonname, column); Grid.SetRow(buttonname, row);
before you add the object to the gridThumb.
We need some more information for what exactly you want to accomplish and what doesn't work for you to help :)
精彩评论