小编And*_*eaG的帖子

MVF中的WPF绑定检查事件

我是MVVM模式的新手,我必须在以下视图中拦截已检查/未检查的操作

SendMessageView.xaml

<ListBox.ItemTemplate>
   <DataTemplate>
      <StackPanel>
         <CheckBox Checked="Specialita_Checked" 
                Unchecked="Specialita_Unchecked"
                Content="{Binding Path=Item.Name}"
                IsChecked="{Binding RelativeSource={RelativeSource FindAncestor,
                            AncestorType={x:Type ListBoxItem}}, 
                            Path=IsSelected,Mode=TwoWay}"/>
      </StackPanel>
   </DataTemplate>
</ListBox.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

SendMessageView.xaml.cs

private void Specialita_Checked(object sender, System.Windows.RoutedEventArgs e)
{
   var aSendMessageViewModel = (SendMessageViewModel)this.DataContext;
   if (aSendMessageViewModel != null)
   {
      var aCheckBox = (CheckBox)sender;
      aSendMessageViewModel.AddSpecialita(aCheckBox.Content.ToString());
   }
}
Run Code Online (Sandbox Code Playgroud)

aSendMessageViewModel.cs调用的文件是在a内调用SendMessageView.xaml.cs,这是不正确的.帮助我正确使用MVVM模式.

wpf mvvm

4
推荐指数
1
解决办法
1万
查看次数

c#TDD第一次在ServiceBase中

我正在尝试第一次实现测试驱动的开发.我的项目是dotnet 3.5中的ac#.我已阅读在C#书中专业测试驱动开发,现在我想测试我的项目包含Windows service.I've读到最好的做法是,所有代码必须在test.The以下是我的窗口服务实现方法onStart和onStop

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using log4net;

namespace MyUcmaService
{
 public partial class MyUcmaService : ServiceBase
 {
    private Worker _workerObject;
    private static MyUcmaService aMyUcmaService;
    private Thread _workerThread;
    private static ILog _log = LogManager.GetLogger(typeof(MyUcmaService));

    public MyUcmaService()
    {
        InitializeComponent();
        aMyUcmaService = this;
    }

    protected override void OnStart(string[] args)
    {
        // TODO: inserire qui il codice necessario per avviare il servizio.
        //Debugger.Launch();
        AppDomain.CurrentDomain.UnhandledException += AppDomainUnhandledException;
        try
        {
            _workerObject = new Worker(); …
Run Code Online (Sandbox Code Playgroud)

tdd nunit ninject moq ninject-2

3
推荐指数
2
解决办法
1540
查看次数

标签 统计

moq ×1

mvvm ×1

ninject ×1

ninject-2 ×1

nunit ×1

tdd ×1

wpf ×1