Image control not getting resized while resizing window
-
Hi , I have a WPF - window, contains a StackPanel (designed in xmal, where height and width are Auto = 0). In code reading an image folder and adding the files to stackPanel. While adding files to image control, created a border object and intern created the image object and fina tlly adding the border to stackpanel. Now when i try to resize the window, the stackpanel stays same size , as the image control width and hight are fixed thou the stackpanel is auto size. below is the code snip , //after reading the image files, add it to stack panel foreach (string strFile in ArrStrFiles) { // display the file names here BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = new Uri(strFile); bi.EndInit(); Image img = new Image(); img.Source = bi; img.Width = 170; img.Height = stkPanl.ActualHeight; img.Stretch = Stretch.Fill; img.HorizontalAlignment = HorizontalAlignment.Stretch; img.VerticalAlignment = VerticalAlignment.Stretch; Border border = new Border(); border.Background = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5); border.BorderBrush = new SolidColorBrush(Colors.Black); border.Child = img; stkPanl.Children.Add(border); } xmal : Plz let me know how we can resize the stackPanel when the image is added thru code. thanks
-
Hi , I have a WPF - window, contains a StackPanel (designed in xmal, where height and width are Auto = 0). In code reading an image folder and adding the files to stackPanel. While adding files to image control, created a border object and intern created the image object and fina tlly adding the border to stackpanel. Now when i try to resize the window, the stackpanel stays same size , as the image control width and hight are fixed thou the stackpanel is auto size. below is the code snip , //after reading the image files, add it to stack panel foreach (string strFile in ArrStrFiles) { // display the file names here BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = new Uri(strFile); bi.EndInit(); Image img = new Image(); img.Source = bi; img.Width = 170; img.Height = stkPanl.ActualHeight; img.Stretch = Stretch.Fill; img.HorizontalAlignment = HorizontalAlignment.Stretch; img.VerticalAlignment = VerticalAlignment.Stretch; Border border = new Border(); border.Background = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5); border.BorderBrush = new SolidColorBrush(Colors.Black); border.Child = img; stkPanl.Children.Add(border); } xmal : Plz let me know how we can resize the stackPanel when the image is added thru code. thanks