textinput mvvm detection
This commit is contained in:
@@ -122,6 +122,8 @@ namespace MVVMDatabaseSample.ViewModel
|
||||
|
||||
private void Select()
|
||||
{
|
||||
_sampleData.Clear();
|
||||
|
||||
DataSet ds = new DataSet();
|
||||
string qry = "SELECT * FROM Student";
|
||||
SqlDBManager.Instance.ExecuteQuery(ds, qry);
|
||||
|
9
PacticeSolution/MVVMTextInputDetection/App.xaml
Normal file
9
PacticeSolution/MVVMTextInputDetection/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="MVVMTextInputDetection.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:MVVMTextInputDetection"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
17
PacticeSolution/MVVMTextInputDetection/App.xaml.cs
Normal file
17
PacticeSolution/MVVMTextInputDetection/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace MVVMTextInputDetection
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
10
PacticeSolution/MVVMTextInputDetection/AssemblyInfo.cs
Normal file
10
PacticeSolution/MVVMTextInputDetection/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
19
PacticeSolution/MVVMTextInputDetection/MainWindow.xaml
Normal file
19
PacticeSolution/MVVMTextInputDetection/MainWindow.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<Window x:Class="MVVMTextInputDetection.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:MVVMTextInputDetection" xmlns:viewmodel="clr-namespace:MVVMTextInputDetection.ViewModel"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="200" Width="200">
|
||||
|
||||
<Window.DataContext>
|
||||
<viewmodel:CalculateViewModel/>
|
||||
</Window.DataContext>
|
||||
|
||||
<Grid>
|
||||
<TextBox x:Name="tbxNumber" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Margin="5"
|
||||
Text="{Binding Number, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextWrapping="Wrap" TextAlignment="Center"/>
|
||||
</Grid>
|
||||
</Window>
|
28
PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs
Normal file
28
PacticeSolution/MVVMTextInputDetection/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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 MVVMTextInputDetection
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
13
PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs
Normal file
13
PacticeSolution/MVVMTextInputDetection/Model/Calculate.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MVVMTextInputDetection.Model
|
||||
{
|
||||
class Calculate
|
||||
{
|
||||
public int Number { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
using MVVMTextInputDetection.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace MVVMTextInputDetection.ViewModel
|
||||
{
|
||||
class CalculateViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public Calculate CalculateModel { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public CalculateViewModel()
|
||||
{
|
||||
this.CalculateModel = new Calculate();
|
||||
}
|
||||
|
||||
public int Number
|
||||
{
|
||||
get { return this.CalculateModel.Number; }
|
||||
set
|
||||
{
|
||||
CalculateModel.Number = value;
|
||||
OnPropertyChanged("Number");
|
||||
|
||||
CheckNumberRange(this.CalculateModel.Number);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckNumberRange(int number)
|
||||
{
|
||||
if (number > 99 || number < 0)
|
||||
MessageBox.Show("Number range exceeded!");
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,13 +9,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClockGadget", "ClockGadget\
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapFinder", "MapFinder\MapFinder.csproj", "{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataBindingSample", "DataBindingSample\DataBindingSample.csproj", "{8A3E4E38-6E95-4955-8BFE-6E58F4AECE27}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataBindingSample", "DataBindingSample\DataBindingSample.csproj", "{8A3E4E38-6E95-4955-8BFE-6E58F4AECE27}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMSample", "MVVMSample\MVVMSample.csproj", "{FFD799B6-18C5-413B-8984-B44C803473B0}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMSample", "MVVMSample\MVVMSample.csproj", "{FFD799B6-18C5-413B-8984-B44C803473B0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceSample", "ResourceSample\ResourceSample.csproj", "{858EC308-9ABD-44C1-92E1-59911F60FEB9}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceSample", "ResourceSample\ResourceSample.csproj", "{858EC308-9ABD-44C1-92E1-59911F60FEB9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMDatabaseSample", "MVVMDatabaseSample\MVVMDatabaseSample.csproj", "{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MVVMDatabaseSample", "MVVMDatabaseSample\MVVMDatabaseSample.csproj", "{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVVMTextInputDetection", "MVVMTextInputDetection\MVVMTextInputDetection.csproj", "{C55A5081-B142-4120-8F62-3991276EF5C2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -51,6 +53,10 @@ Global
|
||||
{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0A8E6DE-C6A2-488E-A148-9E7812F615F2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C55A5081-B142-4120-8F62-3991276EF5C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C55A5081-B142-4120-8F62-3991276EF5C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C55A5081-B142-4120-8F62-3991276EF5C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C55A5081-B142-4120-8F62-3991276EF5C2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Reference in New Issue
Block a user