小编Dev*_*Dan的帖子

将EF4与Caliburn.Micro绑定:我应该将我的实体作为ViewModel的属性公开吗?

使用Caliburn.Micro,我想知道将EF4实体暴露为ViewModel的属性(这里 和此处讨论的一种技术)的优缺点.这使我可以避免为每个字段编写getter和setter(参见下面的OneCustomer).缺点是我需要在XAML中编写所有绑定语句(LastName不在ViewModel中,但需要XAML绑定).如果我坚持使用每个字段的属性填充我的ViewModel的规定技术(如下面的FirstName),我最终必须编写大量的额外代码才能调用NotifyOfProperyChange.该应用程序将非常庞大.我应该将每个实体公开为ViewModel的属性吗?

在我的ViewModel中:

private MyEntities _context = new MyEntities();
private BindableCollection<Customer> _custBindableCollection; 
private Customer _oneCustomer;
private string _firstName;

public void Load() 
{
    _custBindableCollection = new BindableCollection<Customer>(_context.Customers.Where(row => row.CustomerType == "FOO"));
    AllCustomers = _custBindableCollection;
    _oneCustomer = _custBindableCollection.FirstOrDefault();
    FirstName = _oneCustomer.FirstName;
    OneCustomer = _oneCustomer;
}

public BindableCollection<Customer> AllCustomers
{ 
get { return _custBindableCollection;}
set {_custBindableCollection = value;
      NotifyOfPropertyChange(() => AllCustomers);}
}

public Customer OneCustomer
{
 get { return _oneCustomer;}
 set { _oneCustomer = value;
        NotifyOfPropertyChange(() => OneCustomer);}
} 

public …
Run Code Online (Sandbox Code Playgroud)

wpf entity-framework mvvm caliburn.micro

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

RadGrid.Rebind()和RadGrid.MasterTableView.Rebind()有什么区别?

使用RadGrid for Asp.Net Ajax(来自Telerik)我需要重新设置CurrentPageIndex.一些例子说下一行代码应该是myGrid.Rebind(),其他代码建议调用myGrid.MasterTableView.Rebind().有什么不同?我应该使用哪个?

asp.net webforms telerik radgrid

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

如何使用ASP.Net MVC 3链接到两个样式表?

我想在我的ASP.Net MVC 3应用程序中使用Twitter的Bootstrap.我下载了bootstrap.css并将其添加到Content文件夹中的项目中.我打开_Layout.cshtml并添加了一个指向该文件的链接:

<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" />
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序时,不应用样式表.如何从_Layout.cshtml文件中引用Site.css和bootstrap.css?

css asp.net-mvc-3 twitter-bootstrap

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

在Visual Studio 2012中,ClickOnce"发布"期望找到.Net 4客户端配置文件吗?

安装Visual Studio 2012后,"发布"功能停止工作.发布无法找到必备的Microsoft .Net Framework 4 Client Profile(x86和x64).以前在Visual Studio 2010中,这很好用.我使用的是64位Windows 7.

确切的Visual Studio 2012错误消息如下:

Error 104 - To enable 'Download prerequisites from the same location 
as my application' in the Prerequisites dialog box, you must download file
'DotNetFX40Client\dotNetFx40_Client_x86_x64.exe' for item 'Microsoft .NET 
Framework 4 Client Profile (x86 and x64)' to your local machine. For more 
information, see http://go.microsoft.com/fwlink/?LinkId=239883
Run Code Online (Sandbox Code Playgroud)

我把文件dotNetFx40_Client_setup.exe放在了以下位置: C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\Bootstrapper\Packages\DotNetFX40Client

我也将它留在原来的位置(注意v7.0A):

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40Client

编辑(解决问题后):我看到正确的安装文件(dotNetFx40_Client_x86_x64.exe)实际上在v7.0A文件夹中.如果我只是从那里复制它一切都会工作(而不是下载错误的设置).

当我更改"从我的应用程序的相同位置下载先决条件"选项到"从组件供应商的网站下载先决条件"(在项目属性 - >发布 - …

wpf clickonce publishing prerequisites .net-client-profile

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

为什么我的Silverlight BusyIndi​​cator在设置IsBusy = true后仍然不可见?

当DomainDataSource获取数据时,我的BusyIndi​​cator按预期工作.但是当我在代码中将IsBusy设置为true时,控件保持不可见.

我正在使用Silverlight 4和工具包BusyIndi​​cator.在XAML中,我将BusyIndi​​cator.IsBusy属性绑定到我的DomainDataSource控件的IsBusy属性.BusyIndi​​cator控件包装我的主Grid(LayoutRoot)和所有子控件.

<toolkit:BusyIndicator IsBusy="{Binding ElementName=labSampleDomainDataSource, Path=IsBusy}"  Name="busyIndicator1">
<Grid x:Name="LayoutRoot">

</Grid>
</toolkit:BusyIndicator>
Run Code Online (Sandbox Code Playgroud)

问题是当我设置busyIndi​​cator1 = true时BusyIndi​​cator没有显示; 在按钮单击事件中.知道我做错了什么吗?

silverlight silverlight-toolkit silverlight-4.0 busyindicator

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

在将数据从Web服务移动到Sql Server 2005时,如何保留回车?

当作为来自Web服务的NVarChar参数插入Sql Server 2005时,我的回车丢失.我知道回车符存在于Web服务字段中,因为当我将相同的数据绑定到WPF ComboBox时,我看到返回发生在正确的位置.

代码看起来像这样:

string insertSQL = "INSERT INTO myTable (FieldWithCrLf,...) VALUES (@FieldWithCrLf,...)";

dbConn.Open();

using (SqlCommand cmd = new SqlCommand(@insertSQL, dbConn))
    {
        cmd.Parameters.Add("@FieldWithCrLf", SqlDbType.NVarChar, 4000);
        ...
    }

foreach (WebServiceRecord rec in allDataFromWebService)
    {
        cmd.Parameters["@FieldWithCrLfr"].Value = rec.FieldWithCrLfFromWebService;
        ...
        cmd.ExecuteNonQuery();
    }
Run Code Online (Sandbox Code Playgroud)

如何保留回车符/换行符以便它们存储在我的Sql Server字段中?

sql-server wpf xaml web-services

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

如何在设计模式下打开锁定的应用程序?

我们的MS Access 2000开发人员一年前离开了公司.我们需要在设计模式下打开他的应用程序才能进行修改.在按住Shift键的同时双击.mdb文件不起作用.当我这样做时,开发人员工具栏会显示一瞬间,然后所有工具栏都会消失,应用程序会在用户看到它时打开.没有工具栏显示,只有基本仪表板可见才能运行应用程序.我尝试使用此处提到的密码恢复工具,但工具说没有密码.有人能告诉我如何打开这个应用程序来修改代码吗?

ms-access cracking forgot-password

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

添加重复编号后,哪些数字词典集合会重新排序项目?

我的C#程序允许用户按优先级对项目进行数字排名。我编写了一个例程,当用户修改项目等级时,该例程将自动按等级对项目进行排序。因此,当优先级为3的项目更改为1时,例程将诉诸前3个项目。那些先前排名为1、2的项目将成为排名2、3。类似地,当优先级为1的项目成为优先级3时,那些排名为2、3的项目将成为1、2。

现有的集合类是否内置了此功能?如果是这样,代码示例也将不胜感激。

.net c# sorting collections

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