The*_*GIS 2 c# wpf xaml caliburn.micro
我正在通过一个旧的Caliburn Micro教程(这里).我达到第2部分(这里).我已设法更新App.xaml和AppBootstrapper.cs以与3.0.3和WPF兼容(如"文档"页面上的"WPF"部分所述).我正在使用VS 2013.
该教程显示初始化后出现值为"50"的应用程序.我的应用只显示了这个:
这是迄今为止的代码:
App.xaml中
<Application
xmlns:local="clr-namespace:CaliburnMicroApp"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class=" CaliburnMicroApp.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<local:AppBootstrapper x:Key="bootstrapper" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
AppViewModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
namespace CaliburnMicroApp.ViewModels
{
class AppViewModel : PropertyChangedBase
{
private int _count = 50;
private int Count
{
get { return _count; }
set
{
_count = value;
NotifyOfPropertyChange(() => Count);
NotifyOfPropertyChange(() => CanIncrementCount);
}
}
public void IncrementCount()
{
Count++;
}
public bool CanIncrementCount
{
get { return Count < 100; }
}
}
}
Run Code Online (Sandbox Code Playgroud)
AppView.xaml
<UserControl x:Class="CaliburnMicroApp.Views.AppView"
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">
<Grid Width="300" Height="300" Background="LightBlue">
<RepeatButton Name="IncrementCount" Content="Up" Margin="15" VerticalAlignment="Top" />
<TextBlock Name="Count" Margin="20" FontSize="150" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
AppBootstrapper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Caliburn.Micro;
using CaliburnMicroApp.ViewModels;
using System.Windows;
namespace CaliburnMicroApp
{
public class AppBootstrapper : Caliburn.Micro.BootstrapperBase
{
public AppBootstrapper()
{
Initialize();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<AppViewModel>();
}
}
}
Run Code Online (Sandbox Code Playgroud)