Nếu bạn đã từng rất thích thú với việc tự làm dự án thực tế qua serial hướng dẫn lập trình PHẦN MỀM QUẢN LÝ QUÁN CAFE bằng Winform thì chẳng có lý do gì để không tiếp tục nâng cao kinh nghiệm cá nhân với serial lập trình Phần mềm quản lý kho WPF – MVVM này. Không chỉ đề cập đến công nghệ WPF, serial còn kết hợp mô hình MVVM, entity framework, … và nhiều kỹ thuật khác.
Ở bài trước chúng ta đã tìm hiểu về cáchTHIẾT KẾ GIAO DIỆN ĐĂNG NHẬP . Trong bài này, Kteam sẽ giới thiệu đến các bạn cách Tạo ControlBar trong Phần mềm quản lý kho WPF – MVVM.
Nội dung
Nội dung bao gồm Source code & các lưu ý chính về quá trình thực hiện phần mềm. Kteam khuyến khích bạn cập nhập thêm nhiều kinh nghiệm cũng như hiểu chi tiết hơn về các kỹ thuật được đề cập trong bài học thông qua các video đính kèm.
Đừng quên Like Facebook hoặc +1 Google để ủng hộ Kteam và tác giả.
Để theo dõi tốt khóa học này, hãy đảm bảo bạn đã xem qua kiến thức về:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace QuanLyKho
{
///<summary>/// Interaction logic for App.xaml///</summary>publicpartialclass App : Application
{
}
}
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 QuanLyKho
{
///<summary>/// Interaction logic for MainWindow.xaml///</summary>publicpartialclass MainWindow : Window
{
//http://materialdesigninxaml.net/homepublicMainWindow()
{
InitializeComponent();
}
}
}
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 QuanLyKho
{
///<summary>/// Interaction logic for LoginWindow.xaml///</summary>publicpartialclass LoginWindow : Window
{
publicLoginWindow()
{
InitializeComponent();
}
}
}
using QuanLyKho.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 QuanLyKho.UserControlKteam
{
///<summary>/// Interaction logic for ControlBarUC.xaml///</summary>publicpartialclass ControlBarUC : UserControl
{
public ControlBarViewModel Viewmodel { get; set; }
publicControlBarUC()
{
InitializeComponent();
this.DataContext = Viewmodel = new ControlBarViewModel();
}
}
}
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.Input;
namespace QuanLyKho.ViewModel
{
publicclass ControlBarViewModel : BaseViewModel
{
#region commandspublic ICommand CloseWindowCommand { get; set; }
public ICommand MaximizeWindowCommand { get; set; }
public ICommand MinimizeWindowCommand { get; set; }
public ICommand MouseMoveWindowCommand { get; set; }
#endregionpublicControlBarViewModel()
{
CloseWindowCommand = new RelayCommand<UserControl>((p)=> { return p == null? false : true; }, (p)=> {
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
w.Close();
}
}
);
MaximizeWindowCommand = new RelayCommand<UserControl>((p) => { return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Maximized)
w.WindowState = WindowState.Maximized;
else
w.WindowState = WindowState.Normal;
}
}
);
MinimizeWindowCommand = new RelayCommand<UserControl>((p) => { return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
if (w.WindowState != WindowState.Minimized)
w.WindowState = WindowState.Minimized;
else
w.WindowState = WindowState.Maximized;
}
}
);
MouseMoveWindowCommand = new RelayCommand<UserControl>((p) => { return p == null ? false : true; }, (p) =>
{
FrameworkElement window = GetWindowParent(p);
var w = window as Window;
if (w != null)
{
w.DragMove();
}
}
);
}
FrameworkElement GetWindowParent(UserControl p)
{
FrameworkElement parent = p;
while (parent.Parent != null)
{
parent = parent.Parent as FrameworkElement;
}
return parent;
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Tải Project
Nếu việc thực hành theo hướng dẫn không diễn ra suôn sẻ như mong muốn. Bạn cũng có thể tải xuống PROJECT THAM KHẢO ở link bên dưới!
Kết
Trong bài này, chúng ta đã tìm hiểu cách phân tích đặc tả phần mềm quản lý kho.
Ở bài sau, Kteam sẽ giới thiệu đến bạn cách THIẾT KẾ MÀN HÌNH CHÍNH TRONG PHẦN MỀM QUẢN LÝ KHO WPF – MVVM.
Cảm ơn các bạn đã theo dõi bài viết. Hãy để lại bình luận hoặc góp ý của mình để phát triển bài viết tốt hơn. Và đừng quên “Luyện tập – Thử Thách – Không ngại khó”
Tải xuống
Tài liệu
Nhằm phục vụ mục đích học tập Offline của cộng đồng, Kteam hỗ trợ tính năng lưu trữ nội dung bài học Tạo ControlBar trong Phần mềm quản lý kho WPF - MVVM dưới dạng file PDF trong link bên dưới.
Ngoài ra, bạn cũng có thể tìm thấy các tài liệu được đóng góp từ cộng đồng ở mục TÀI LIỆU trên thư viện Howkteam.com
Đừng quên like và share để ủng hộ Kteam và tác giả nhé!
Thảo luận
Nếu bạn có bất kỳ khó khăn hay thắc mắc gì về khóa học, đừng ngần ngại đặt câu hỏi trong phần bên dưới hoặc trong mục HỎI & ĐÁP trên thư viện Howkteam.com để nhận được sự hỗ trợ từ cộng đồng.
Nếu bạn đã từng rất thích thú với việc tự làm dự án thực tế qua serial hướng dẫn lập trình
PHẦN MỀM QUẢN LÝ QUÁN CAFE bằng Winform thì chẳng có lý do gì để không tiếp tục nâng cao kinh nghiệm cá nhân với serial lập trìnhPhần mềm quản lý kho WPF – MVVM.
Serial Phần mềm quản lý kho sử dụng công nghệ WPF cùng với mô hình
MVVM, sử dụng entity framework và theme giao diện của WPF Material design,... cùng rất nhiều kỹ thuật, kinh nghiệm khác.
Không có gì tuyệt vời hơn là luyện tập với dự án thực tế. Nào cùng nhau thử thách bản thân với
phần mềm Quản lý kho WPF – MVVM.
hi anh Long, cho mình hỏi là mình đang phân Model và ViewModel ra thành project riêng,
Trong phần MainResource để có thể gọi MainViewModel mình phải add referrence vào rồi => View đã add referrece của ViewModel
khi tới chổ MainViewBase, lúc check IsLoad thì có gọi LoginWindow lên cho show ra, nhưng vấn đề ở đây là ko add referrence ngược lại được thì làm sao mình gọi LoginWindow đc.
ai giúp em phần login form được không ạ, em làm theo mà bị hiển thị 2 lần login form ạ :((
hi anh Long, cho mình hỏi là mình đang phân Model và ViewModel ra thành project riêng,
Trong phần MainResource để có thể gọi MainViewModel mình phải add referrence vào rồi => View đã add referrece của ViewModel
khi tới chổ MainViewBase, lúc check IsLoad thì có gọi LoginWindow lên cho show ra, nhưng vấn đề ở đây là ko add referrence ngược lại được thì làm sao mình gọi LoginWindow đc.
Mong được hồi âm.
Thanks
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Name="ucControlBar"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName = "MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding MouseMoveWindowCommand}" CommandParameter="{Binding ElementName=ucControlBar}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
đoạn này em cài rồi mà sao vẫn báo lỗi admin ạ lỗi i:Interaction.Triggers ấy ạ bị gạch đít màu xanh
biến IsLoaded trong MainViewModel để làm gì vậy Ad?
Có hàm public static Window GetWindow(DependencyObject dependencyObject); ở class Window để lấy cái Window mà UserControl nó nằm.