Проблема из событиями у UserControl

116
07 апреля 2018, 19:20

Есть Usercontrol которий находится у папке Vkstatistics/Templates. Vkstatistics - им'я проекта. Проблема состоится в том что при визове события (нажатия кнопки, наведения фокуса курсора мыши) выбивает ошибка: 'LoginControl" не содержит определения для "Send_Data_Button" и не удалось найти метод расширения "Send_Data_Button", принимающий тип "LoginControl" в качестве первого аргумента (возможно, пропущена директива using или ссылка на сборку)

LoginContrl.xaml

<UserControl x:Class="VkStatistic.Templates.LoginControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:VkStatistic.Templates"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Height="400" Width="600">
    <Grid Background="#FF878282">
        <TextBlock HorizontalAlignment="Center"
                   Margin="0 70 0 0"
                  FontSize="18"
                  Foreground="Black">
                For continue you must pass authorization
        </TextBlock>
        <TextBlock FontSize="15"
                       HorizontalAlignment="Center"
                       Margin="0 100 0 0"
                       Foreground="Gray">
                    Login in your exist account VK
        </TextBlock>
        <StackPanel VerticalAlignment="Center" Height="150" Width="200"
                    Margin="0 50 0 0">
            <TextBlock Margin="25 0 0 0">Input email or phone</TextBlock>
            <TextBox 
                 x:Name="LoginBox"
                 HorizontalAlignment="Center"
                 Height="25" Width="150"
                Margin="0 0 0 0"
                Focusable="True"
                GotFocus="GotFocusLogin"
                LostFocus="LostFocusLogin"
                />
            <TextBlock Margin="25 15 0 0">Input password</TextBlock>
            <PasswordBox 
                 x:Name="PaswrdBox"
                 HorizontalAlignment="Center"
                 Height="25" Width="150"
                 />

            <Button x:Name="LoginButton"
                    Height="25" Width="70"
                    Margin="80 15 0 0"
                    Content="Log in"
                    Click="Send_Data_Button"/>
        </StackPanel>

    </Grid>
</UserControl>

LoginControl.xaml.cs

using System;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Media;
using VkStatistic.Templates;
namespace VkStatistic.Templates
{
    /// <summary>
    /// Логика взаимодействия для LoginControl.xaml
    /// </summary>
    public partial class LoginControlVM: UserControl
    {
        public LoginControlVM()
        {
            InitializeComponent();
            RegisterStyle();
        }
        void RegisterStyle()
        {
            LoginBox.Text = "email or phone";
            LoginBox.Foreground = new SolidColorBrush(Colors.Gray);
        }

        private void GotFocusLogin(object sender, EventArgs e)
        {
            TextBox txt = sender as TextBox;
            if (txt.Text == "email or phone")
            {
                txt.Foreground = new SolidColorBrush(Colors.Black);
                txt.Text = "";
            }
        }
        void LostFocusLogin(object sender, EventArgs e)
        {
            TextBox txt = sender as TextBox;
            if (txt.Text == "")
            {
                txt.Text = "email or phone";
                txt.Foreground = new SolidColorBrush(Colors.Gray);
            }
        }

        void Send_Data_Button(object sender, EventArgs e)
        {
            string login = LoginBox.Text;
            string password = PaswrdBox.Password.ToString();
            Debug.WriteLine(password);
        }

    }
}

Использую его у главном окне:

<Window.Resources>
        <DataTemplate DataType="{x:Type vms:LoginControlV}">
            <vms:LoginControl/>
        </DataTemplate>
           .........................................
</Window.Resources>
    <ContentPresenter Content="{Binding CurrentContentVM}"/>

Использую паттерн MVVM, в чем может быть проблема???

Answer 1

У вас

public partial class LoginControlVM: UserControl
{
    public LoginControlVM()
    {

A должно быть

public partial class LoginControl: UserControl
{
    public LoginControl()
    {
READ ALSO
Работа с Video Player Unity3D

Работа с Video Player Unity3D

Есть камера, на которой скрипт и есть куб на котором должен воспроизводиться один из видеороликов (в зависимости от выбранного 3DTexta)Подскажите...

154
EF error: Store update, insert, or delete statement affected an unexpected number of rows (0)

EF error: Store update, insert, or delete statement affected an unexpected number of rows (0)

Есть метод, который добавляет запись в БД

152
Помощь новичку который вообще не шарит в программировании [требует правки]

Помощь новичку который вообще не шарит в программировании [требует правки]

Я не понимаю ,что такое фреймворки ,для чего они нужныТакже я не понимаю ,разве можно совмещать языки программирования,если да то как?Помогите...

159
Как отслеживать координаты Обьекта

Как отслеживать координаты Обьекта

Мне для игры нужно сделать 3D миникарту, но не знаю как отслеживать все координаты персонажаИгра на C#, Unity

178