Click here to Skip to main content
15,886,046 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to understand some things using examples. I'm trying to make a Windows app for league of legends that i can click my summoner name and get my ranked stats so I used an examples to follow but I am kind of stuck now.

The problem is that I'm stuck on how to make it appear on form. I'm still learning things so be kind please.

I used this example: [url]https://github.com/Abel13/LoLGoal/tree/get_profile_data/LoLGoal[/url]


I'm stuck at the part of making these work into Windows Forms:

C#
<Window x:Class="LoLGoal.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:LoLGoal"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        mc:Ignorable="d" Height="600" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Background="#FF410A66">
    <Grid>
        <StackPanel Margin="50">
            <Image Source="/Assets/logo2.png" Width="96" Height="96"/>
            <Border Background="White" Margin="10 20" CornerRadius="5">
                <StackPanel Margin="25">
                    <ComboBox Margin="15" Style="{StaticResource MaterialDesignFloatingHintComboBox}" materialDesign:HintAssist.Hint="Region" Text="{Binding Region}">
                        <ComboBoxItem Content="RU"/>
                        <ComboBoxItem Content="KR"/>
                        <ComboBoxItem Content="BR1"/>
                        <ComboBoxItem Content="OC1"/>
                        <ComboBoxItem Content="JP1"/>
                        <ComboBoxItem Content="NA1"/>
                        <ComboBoxItem Content="EUN1"/>
                        <ComboBoxItem Content="EUW1"/>
                        <ComboBoxItem Content="TR1"/>
                        <ComboBoxItem Content="LA1"/>
                        <ComboBoxItem Content="LA2"/>
                    </ComboBox>
                    <TextBox Text="{Binding SummonerName}" Margin="15" Style="{StaticResource MaterialDesignFloatingHintTextBox}" materialDesign:HintAssist.Hint="Summoner"/>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <Button Margin="15 50" Content="CANCEL"/>
                        <Button x:Name="ButtonSignUp" Margin="15 50" Content="SEARCH" Click="ButtonSignUp_Click"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </StackPanel>
    </Grid>
</Window>


using LoLGoal.Controller;
using LoLGoal.View;
using LoLGoal.View.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LoLGoal
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        ControllerMain controller;
        ViewModelMain viewModel;
        public MainWindow()
        {
            controller = new ControllerMain();
            viewModel = new ViewModelMain();
            InitializeComponent();

            this.DataContext = viewModel;
        }

        private void ButtonSignUp_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(viewModel.Region))
                return;
            if (string.IsNullOrEmpty(viewModel.SummonerName))
                return;

            if(controller.GetSummoner(viewModel.SummonerName))
            {
                WindowProfile profile = new WindowProfile();
                profile.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Not Found");
            }
        }
    }
}


using LoLGoal.Controller;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LoLGoal.View
{
    /// <summary>
    /// Interaction logic for WindowProfile.xaml
    /// </summary>
    public partial class WindowProfile : Window
    {
        ControllerProfile controller;

        public WindowProfile()
        {
            controller = new ControllerProfile();
            InitializeComponent();
            this.DataContext = controller.GetContext();
        }

        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            controller.OpenMain();
            this.Close();
        }
    }
}


What I have tried:

using AeonApp.Controller;
using AeonApp.View.ViewModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AeonApp.View
{
    public partial class MainWindow : Form
    {
        ControllerMain controller;
        ViewModelMain viewModel;
        public MainWindow()
        {
            controller = new ControllerMain();
            viewModel = new ViewModelMain();
            InitializeComponent();

            this.DataContext = viewModel;
        }

        public ViewModelMain DataContext { get; }

        private void MainWindow_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(viewModel.Region))
                return;
            if (string.IsNullOrEmpty(viewModel.SummonerName))
                return;

            if (controller.GetSummoner(viewModel.SummonerName))
            {
                WindowProfile profile = new WindowProfile();
                profile.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Not Found");
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

using AeonApp.Controller;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AeonApp.View
{
    public partial class WindowProfile : Form
    {
        ControllerProfile controller;

        public object DataContext { get; }

        public WindowProfile()
        {
            controller = new ControllerProfile();
            InitializeComponent();
            this.DataContext = controller.GetContext();
        }

        private void WindowProfile_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            controller.OpenMain();
            this.Close();
        }
    }
}
Posted
Comments
RickZeeland 2-May-20 5:53am    
I think you picked a bad example to begin with, it's an MVC (Model View Controller) application which is overkill and too complicated for what you want. Just create a new Winforms application and take a look at the Microsoft documentation, much simpler !
#realJSOP 4-May-20 8:21am    
As an aside, whoever designed that WPF form absolutely sucks at designing WPF forms.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900