小编And*_*yUK的帖子

使用MVVM在wpf中使用Dialogs的好坏?

我最近遇到了为我的wpf应用程序创建添加和编辑对话框的问题.

我想在代码中做的就是这样.(我主要使用viewmodel第一种方法与mvvm)

调用对话框窗口的ViewModel:

var result = this.uiDialogService.ShowDialog("Dialogwindow Title", dialogwindowVM);
// Do anything with the dialog result
Run Code Online (Sandbox Code Playgroud)

它是如何工作的?

首先,我创建了一个对话服务:

public interface IUIWindowDialogService
{
    bool? ShowDialog(string title, object datacontext);
}

public class WpfUIWindowDialogService : IUIWindowDialogService
{
    public bool? ShowDialog(string title, object datacontext)
    {
        var win = new WindowDialog();
        win.Title = title;
        win.DataContext = datacontext;

        return win.ShowDialog();
    }
}
Run Code Online (Sandbox Code Playgroud)

WindowDialog是一个特殊而简单的窗口.我需要它来保留我的内容:

<Window x:Class="WindowDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    Title="WindowDialog" 
    WindowStyle="SingleBorderWindow" 
    WindowStartupLocation="CenterOwner" SizeToContent="WidthAndHeight">
    <ContentPresenter x:Name="DialogPresenter" Content="{Binding .}">

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

wpf中对话框的问题是dialogresult = true只能在代码中实现.这就是为什么我为我dialogviewmodel实现它的界面.

public class …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf modal-dialog mvvm

145
推荐指数
3
解决办法
6万
查看次数

如何将WiX安装程序版本设置为当前版本?

我编写了一个应用程序及其WiX安装程序,并使用subversion将其置于版本控制之下.当WiX安装程序构建时,我希望其版本号是应用程序的当前构建版本.我该如何做到这一点?我使用c#来编写应用程序代码.

NB我正在使用ccnet来构建这个项目

c# svn wix

125
推荐指数
6
解决办法
6万
查看次数

如何根据我的应用程序版本自动设置Inno Setup安装程序的版本?

我正在使用Inno Setup生成我的应用程序的安装程序.如何设置VersionInfoVersionInno生成的setup.exe()的版本号自动匹配我的应用程序的版本号?现在,每次部署新版本的应用程序时,我都需要手动更新版本号.

现在我这样做:

[Setup]
VersionInfoVersion=1.2.2.0 //writing the value manually
Run Code Online (Sandbox Code Playgroud)

我想要这样的东西:

[Setup]
VersionInfoVersion={Get the version of my app}
Run Code Online (Sandbox Code Playgroud)

inno-setup

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

C++ IsFloat函数

有没有人知道确定字符串值是否"合格"为浮点数的便捷方法?

bool IsFloat( string MyString )
{
   ... etc ...

   return ... // true if float; false otherwise
}
Run Code Online (Sandbox Code Playgroud)

c++ string floating-point

24
推荐指数
5
解决办法
3万
查看次数

在C++软件中加入共享软件限制

我希望在共享软件的基础上实现我的软件,以便为用户提供最长的试用期(比方说)30天,以便试用该软件.在购买时,我打算给用户一个随机生成的密钥,输入时再次启用该软件.

我以前从来没有走过这条路,所以任何建议或反馈或指向"标准"方法的指示都将非常感激.

我不期望用户通过更改系统日期或类似的东西来作弊,尽管这可能值得考虑.如果此话题出现过,请道歉.

c++ time shareware restriction

11
推荐指数
1
解决办法
1342
查看次数

修剪/删除字符串中的选项卡("\ t")

任何人都可以建议一种从字符串中剥离制表符("\ t")的方法吗?CString或std :: string.

例如,"1E10"变为"1E10".

谢谢你的期待.

c++ string tabs

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

处理浮点数中的精度问题

我想知道是否有办法克服精确度问题,这似乎是我的机器内部表示浮点数的结果:

为清楚起见,问题归纳为:

// str is "4.600";   atof( str ) is 4.5999999999999996  
double mw = atof( str )  

// The variables used in the columns calculation below are:   
//  
//                    mw = 4.5999999999999996  
//                    p = 0.2  
//                    g = 0.2  
//                    h = 1 (integer)  

int columns = (int) ( ( mw - ( h * 11 * p ) ) / ( ( h * 11 * p ) + g ) ) + 1;
Run Code Online (Sandbox Code Playgroud)

在转换为整数类型之前,列计算的结果是1.9999999999999996; 距离2.0的理想结果还差不多.

任何建议最受欢迎.

c++ floating-point floating-accuracy

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

在XAML中将静态方法/函数绑定到Func <T>属性

我正在使用XAML创建一个对象树,其中一个节点如下所示:

public class ExecuteMethod : INode
{
    #region Implementation of INode

    public bool Evaluate()
    {
        return Function != null && Function();
    }

    public string Name { get; set; }

    private string _type;
    public string Type
    {
        get
        {
            if (string.IsNullOrEmpty(_type))
            {
                _type = GetType().Name;
            }

            return _type;
        }
    }


    #endregion

    public Func<bool> Function { get; set; }

}
Run Code Online (Sandbox Code Playgroud)

我的目标是使XAML和代码尽可能干净是必不可少的,现在我不是在为每个函数创建包装器属性:

public static Func<bool> Func1 { get { return Method1; } }

public static bool Method1()
{
    //Do stuff here
    return true; …
Run Code Online (Sandbox Code Playgroud)

data-binding wpf xaml binding c#-4.0

9
推荐指数
2
解决办法
3013
查看次数

返回时,完全停止递归

我做递归以在List中找到一个具有多个子节点的长值,这些子节点也可以有子节点.

以下方法:

public TaxonomyData getTaxonomyData(long taxId, List<TaxonomyData> TaxonomyTree, TaxonomyData output)
{
    //find taxid in the taxonomy tree list and return the taxonomydata

    foreach (TaxonomyData td in TaxonomyTree)
    {
        if (td.TaxonomyId == taxId)
        {
                output = td;
                //return td; => when doing a return here means I already found a match so it is not necessary to do all the recursion.
        }
        else if (td.Taxonomy.Length > 0)
        {
            getTaxonomyData(taxId, td.Taxonomy.ToList(), output);
        }
    }

    return output;
}
Run Code Online (Sandbox Code Playgroud)

有可能当我这样做return td;(见注释行)我的整个递归停止了吗?

谢谢

c# asp.net recursion

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

C++中的三维整数数组

我想找到在C++中实现三维整数数组的安全方法,使用指针算术/动态内存分配,或者使用STL矢量等技术.

基本上我希望我的整数数组维度看起来像:

[ x ][ y ][ z ]
Run Code Online (Sandbox Code Playgroud)

x和y在20-6000范围内是已知的并且等于4.

c++ arrays multidimensional-array

7
推荐指数
3
解决办法
3万
查看次数