diff --git a/WpfMvvmChart1/ViewModels/User1ViewModel.cs b/WpfMvvmChart1/ViewModels/User1ViewModel.cs new file mode 100644 index 0000000..ea8a30a --- /dev/null +++ b/WpfMvvmChart1/ViewModels/User1ViewModel.cs @@ -0,0 +1,15 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WpfMvvmChart1.ViewModels +{ + public partial class User1ViewModel:ObservableObject + { + [ObservableProperty] + string title = "TayUserControl"; + } +} diff --git a/WpfMvvmChart1/Views/MainWindow.xaml b/WpfMvvmChart1/Views/MainWindow.xaml index eeb0eeb..0bc297c 100644 --- a/WpfMvvmChart1/Views/MainWindow.xaml +++ b/WpfMvvmChart1/Views/MainWindow.xaml @@ -4,13 +4,16 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:WpfMvvmChart1.ViewModels" - xmlns:local="clr-namespace:WpfMvvmChart1" + xmlns:local="clr-namespace:WpfMvvmChart1.Views" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> + + + diff --git a/WpfMvvmChart1/Views/UserControl1.xaml b/WpfMvvmChart1/Views/UserControl1.xaml new file mode 100644 index 0000000..9b58ceb --- /dev/null +++ b/WpfMvvmChart1/Views/UserControl1.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/WpfMvvmChart1/Views/UserControl1.xaml.cs b/WpfMvvmChart1/Views/UserControl1.xaml.cs new file mode 100644 index 0000000..e3ffea5 --- /dev/null +++ b/WpfMvvmChart1/Views/UserControl1.xaml.cs @@ -0,0 +1,30 @@ +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; +using WpfMvvmChart1.ViewModels; + +namespace WpfMvvmChart1.Views +{ + /// + /// UserControl1.xaml 的交互逻辑 + /// + public partial class UserControl1 : UserControl + { + public UserControl1() + { + InitializeComponent(); + this.DataContext = new User1ViewModel(); + } + } +}