小编Tim*_*ver的帖子

如何在MVVM应用程序中的视图之间导航时保​​留视图的完整状态?

我有一个MVVM应用程序,需要在屏幕之间进行基本的向后/向前导航.目前,我已经使用WorkspaceHostViewModel实现了这一点,它跟踪当前工作空间并公开必要的导航命令,如下所示.

public class WorkspaceHostViewModel : ViewModelBase
{
    private WorkspaceViewModel _currentWorkspace;
    public WorkspaceViewModel CurrentWorkspace
    {
        get { return this._currentWorkspace; }
        set
        {
            if (this._currentWorkspace == null
                || !this._currentWorkspace.Equals(value))
            {
                this._currentWorkspace = value;
                this.OnPropertyChanged(() => this.CurrentWorkspace);
            }
        }
    }

    private LinkedList<WorkspaceViewModel> _navigationHistory;

    public ICommand NavigateBackwardCommand { get; set; }
    public ICommand NavigateForwardCommand { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我还有一个WorkspaceHostView绑定到WorkspaceHostViewModel,如下所示.

<Window x:Class="MyNavigator.WorkspaceHostViewModel"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Window.Resources>
    <ResourceDictionary Source="../../Resources/WorkspaceHostResources.xaml" />
  </Window.Resources>

  <Grid>
    <!-- Current Workspace -->
    <ContentControl Content="{Binding Path=CurrentWorkspace}"/>
  </Grid>

</Window>
Run Code Online (Sandbox Code Playgroud)

在WorkspaceHostResources.xaml文件中,我将WPF用于使用DataTemplates呈现每个WorkspaceViewModel的View关联起来.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:MyNavigator"> …
Run Code Online (Sandbox Code Playgroud)

navigation wpf datatemplate mvvm

12
推荐指数
2
解决办法
7028
查看次数

Microsoft Windows上的DisabledByDefault和Enabled SSL/TLS注册表项之间有什么区别?

Microsoft提供传输层安全性(TLS)的最佳实践指南.本文档介绍了可以启用或禁用特定协议的注册表项.

https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls#configuring-schannel-protocols-in-the-windows-registry

例如,要启用TLS 1.2,您可以添加以下注册表项.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:FFFFFFFF

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:FFFFFFFF
Run Code Online (Sandbox Code Playgroud)

DisabledByDefault和之间有什么区别Enabled?他们似乎多余.

windows ssl schannel

11
推荐指数
2
解决办法
5705
查看次数

使用RegionManager.RequestNavigate方法添加视图时,有没有办法从Prism区域中删除视图(按名称)?

我在我的WPF MVVM应用程序中使用Prism进行导航.我注册我的观点如下.

// MyView is the data type of the view I want to register and "MyView"
// is the name by which I want the data type to be identified within
// the IoC container.
_container.RegisterType<object, MyView>("MyView");
Run Code Online (Sandbox Code Playgroud)

我按如下方式显示此视图.

_regionManager.RequestNavigate(
    "MyRegion", // This is the name of the Region where the view should be displayed.
    "MyView" // This is the registered name of the view in the IoC container.
);
Run Code Online (Sandbox Code Playgroud)

在应用程序的其他地方,我需要在事件处理程序中删除此视图; 但是,以下代码返回一个ArgumentNullException.

_regionManager.Regions["MyRegion"].Remove(
    _regionManager.Regions["MyRegion"].GetView("MyView")
);
Run Code Online (Sandbox Code Playgroud)

这表明,该 …

c# navigation wpf prism mvvm

9
推荐指数
1
解决办法
7199
查看次数

有没有办法使用SQL在IBM System i(aka iSeries/AS400)上更改用户密码?

我有一个C#.NET应用程序,必须能够更改IBM System i(iSeries/AS400)计算机上的用户密码.我目前正在使用以下代码使用IBM专有的cwbx.dll执行此操作.

using cwbx;

public void ChangePassword(string system, string user, string currentPassword, string newPassword)
{
    AS400System as400 = new AS400System();
    as400.Define(system);
    try
    {
        as400.ChangePassword(user, currentPassword, newPassword);
    }
    finally
    {
        as400.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
    }
}
Run Code Online (Sandbox Code Playgroud)

这很好用,但迫使我(以及应用程序的所有用户)对cwbx.dll采取专有依赖.我想消除这种依赖.

有没有办法使用类似于MS SQL Server alter login机制的SQL更改密码?

我知道我可以使用IBM.Data.DB2.iSeries .NET数据提供程序通过使用以下代码从SQL 集成DB2通用数据库for iSeries与iSeries与Microsoft ADO .NET调用程序来实现此目的.

/// <summary>
/// Call a program directly on the iSeries with parameters
/// </summary>
public string CallPgm(string cmdtext)
{
    string rc = " ";

    // Construct a string …
Run Code Online (Sandbox Code Playgroud)

c# sql passwords db2 ibm-midrange

7
推荐指数
1
解决办法
2960
查看次数

如何单元测试BackgroundWorker + PRISM InteractionRequest?

我的WPF MVVM应用程序中有一个重复发生的模式,具有以下结构.

public class MyViewModel : NotificationObject
{
    private readonly IService _DoSomethingService;

    private bool _IsBusy;
    public bool IsBusy
    {
        get { return _IsBusy; }
        set
        {
            if (_IsBusy != value)
            (
                _IsBusy = value;
                RaisePropertyChanged(() => IsBusy);
            )
        }
    }

    public ICommand DisplayInputDialogCommand { get; private set; }
    public InteractionRequest<Notification> Error_InteractionRequest { get; private set; }
    public InteractionRequest<Confirmation> GetInput_InteractionRequest { get; private set; }

    // ctor
    public MyViewModel(IService service)
    {
        _DoSomethingService = service;

        DisplayInputDialogCommand  = new DelegateCommand(DisplayInputDialog);
        Error_InteractionRequest = new …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing prism mvvm backgroundworker

5
推荐指数
1
解决办法
2506
查看次数

为什么数据驱动单元测试在vs2012中在vs2010中正常工作时失败了?

我有一些数据驱动的单元测试在Visual Studio 2010中运行得很好.这些测试使用以下模式实现.

[TestMethod()]
[DeploymentItem("path_to_data_dir_relative_to_solution\\my_data.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\my_data.xml", "Token", DataAccessMethod.Sequential)]
public void MyTestMethod()
{
    // Arrange
    const string EXPECTED_PARAM_NAME = "table";
    string data = TestContext.DataRow["Data"].ToString();
    var sut = new MyClassUnderTest();

    // Act
    sut.DoSomething(data);

    // Assert
    Assert.IsTrue(sut.DidSomething);
}
Run Code Online (Sandbox Code Playgroud)

这是我的解决方案结构.

  • MySolutionFolder
    • MyTestProjectFolder
    • MyTestDataFolder
      • my_data.xml

当我在Visual Studio 2012中运行相同的测试时,它们失败并显示以下错误消息.

结果消息:单元测试适配器无法连接到数据源或读取数据.有关解决此错误的详细信息,请参阅MSDN Library中的"数据驱动单元测试疑难解答"(http://go.microsoft.com/fwlink/?LinkId=62412).错误详细信息:对象引用未设置为对象的实例.

为什么我的单元测试突然失败了?

c# data-driven-tests visual-studio-2010 deploymentitem visual-studio-2012

5
推荐指数
1
解决办法
7258
查看次数

在wpf中动态地将列添加到DataGrid

我目前正在制作一个自定义画布,并且我必须添加一个表,所以我认为dataGrid会很好.所以我想从"Datagrid"创建一个" 表",用户可以在运行时将一个表添加到画布.

直到现在,我已经尝试使用列表填充DataGrid并成功.

如何在运行时将列添加到Datagrid,以便在运行时使用文本框从用户获取列数和标题值,并基于文本框的值,datagrid应添加列和标题值.

实际上我想开发一个表,其中用户传递no的列和列标题,并且应该生成表.

要么

"你能否建议我使用DrawingVisual类"绘制"表格"

它是GraphicsTable类的一部分

//Custom Classes "DrawingCanvas & GraphicsTable" 
public void CreateDataGrid(GraphicsTable graphicsTable, DrawingCanvas drawingCanvas)
{
    dt = new DataGrid();
    dt.Name = "Data";
    dt.ItemsSource = person();
    dt.AllowDrop = true;
    dt.AutoGenerateColumns = true;
    dt.Height = graphicsTable.Rectangle.Height;
    dt.Width = graphicsTable.Rectangle.Width;
    drawingCanvas.Children.Add(dt);
    Canvas.SetTop(dt, graphicsTable.Rectangle.Top);
    Canvas.SetLeft(dt, graphicsTable.Rectangle.Left);
    dt.Width = dt.Width;
    dt.Height = dt.Height;
    dt.Focus();
}
//I have just tried to add dome dummy data to the datagrid.

public List<Person> person()
{
    List<Person> peep = new List<Person>();
    peep.Add(new …
Run Code Online (Sandbox Code Playgroud)

c# wpf wpfdatagrid drawingvisual

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

引用如何位于.NET中?

.NET在运行时使用什么进程来定位引用的程序集,它是否与编译期间用于定位引用程序集的进程不同?我特别感兴趣的是搜索的位置及其搜索顺序以及可能影响结果的任何参数/配置设置.

.net project-reference assembly-references

3
推荐指数
1
解决办法
1904
查看次数