コード例 #1
0
        private void AddLibrariToUser_Click(object sender, RoutedEventArgs e)
        {
            var Librari = new UserLibrari()
            {
                Name = LibrariName_button.Text,
                Link = PhotoLinkString
            };

            user.userLibraris.Add(Librari);
            var LibrariPage = new Librari();

            NavigationService.Navigate(LibrariPage);
        }
コード例 #2
0
ファイル: Librari.xaml.cs プロジェクト: rochoMonsta/MyApp
        public Button CreateNewLibrariButton(UserLibrari userLibrari)
        {
            Button button = new Button();

            button.Margin      = new Thickness(5);
            button.Style       = (Style)FindResource("myButtonStyle");
            button.Click      += new RoutedEventHandler(YourButtonClick);
            button.BorderBrush = null;

            ImageBrush imageBrush = new ImageBrush();

            try
            {
                imageBrush.ImageSource = new BitmapImage(new Uri(userLibrari.Link));
            }
            catch (Exception)
            {
                imageBrush.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/Resources/screen-0.jpg"));
            }
            imageBrush.Stretch = Stretch.UniformToFill;
            button.Background  = imageBrush;

            StackPanel stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Horizontal;
            stackPanel.Background  = Brushes.Black;
            stackPanel.Opacity     = new Double();
            stackPanel.Opacity     = 0.8;
            stackPanel.Height      = 30;

            TextBlock textBlock = new TextBlock();

            textBlock.Text                = userLibrari.Name;
            textBlock.Foreground          = Brushes.White;
            textBlock.HorizontalAlignment = HorizontalAlignment.Stretch;
            textBlock.TextAlignment       = TextAlignment.Center;
            textBlock.VerticalAlignment   = VerticalAlignment.Center;
            textBlock.FontSize            = 14;
            textBlock.FontWeight          = FontWeights.Light;
            textBlock.FontFamily          = new FontFamily("helvetica");
            textBlock.Margin              = new Thickness(3, 0, 3, 0);
            stackPanel.Children.Add(textBlock);

            button.Content = stackPanel;
            return(button);
        }