自定义面板三

承接上篇文章,界面元素如下:

<Window x:Class="PanelChilrenMove.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="1080" Width="1920"  Loaded="Window_Loaded" WindowStartupLocation="CenterScreen" >
    <Grid>
        <my1:SemiCircalPanel  Name="panelControl1" Margin="1230,0,0,0" />
    </Grid>

</Window>


后台调用代码:

 private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string root = AppDomain.CurrentDomain.BaseDirectory + "images"; ;
            string[] files = Directory.GetFiles(root);
            foreach (string file in files)
            {
                Image img = new Image();
                BitmapImage bit = new BitmapImage();
                bit.BeginInit();
                bit.UriSource = new Uri(file, UriKind.RelativeOrAbsolute);
                bit.CacheOption = BitmapCacheOption.OnLoad;
                bit.EndInit();
                img.Source = bit;
                panelControl1.Children.Add(img);
            }
        }



猜你喜欢

转载自blog.csdn.net/feitiankoulan/article/details/22387923