我有一个容器视图,看起来像这样
<UserControl x:Class="Views.ContainerView">
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate DataType="{x:Type viewmodels:AViewModel}">
<views:MyView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:BViewModel}">
<views:MyView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:CViewModel}">
<views:MyView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:DViewModel}">
<views:MyView />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<ListBox ItemsSource="{Binding Path=AvailableViewModels}"
SelectedItem="{Binding Path=CurrentViewModel}"
IsSynchronizedWithCurrentItem="True" />
<ContentControl Content="{Binding Path=CurrentViewModel}" />
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
我的所有视图模型都继承了BaseViewModel,因此我将视图转换为此视图
<UserControl x:Class="Views.ContainerView">
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate DataType="{x:Type viewmodels:BaseViewModel}">
<views:MyView />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<StackPanel>
<ListBox ItemsSource="{Binding Path=AvailableViewModels}"
SelectedItem="{Binding Path=CurrentViewModel}"
IsSynchronizedWithCurrentItem="True" />
<ContentControl Content="{Binding Path=CurrentViewModel}" />
</StackPanel>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
认为它只会实例化一个MyView,并在ListBox.SelectedItem更改时重新绑定viewmodel.我是否正确理解了这种行为?这是首选做法吗?当我在视图之间切换时,如何验证我没有搅拌内存?
考虑以下课程
public class Class1
{
public int A { get; set; }
public int B { get; set; }
public int GetComplexResult()
{
return A + B;
}
}
Run Code Online (Sandbox Code Playgroud)
为了使用GetComplexResult,该类的使用者必须知道在调用该方法之前A和B之前.如果GetComplexResult访问许多属性来计算其结果,如果使用者未首先设置所有适当的属性,则可能导致错误的返回值.所以你可以这样写这个类
public class Class2
{
public int A { get; set; }
public int B { get; set; }
public int GetComplexResult(int a, int b)
{
return a + b;
}
}
Run Code Online (Sandbox Code Playgroud)
这样,调用者GetComplexResult被强制传递所有需要的值,确保正确计算预期的返回值.但是如果有许多必需的值,参数列表也会增长,这似乎也不是好的设计.它似乎也破坏了封装的重点A,B并且GetComplexResult在单个类中.我甚至可能想要创建GetComplexResult静态,因为它不需要类的实例来完成它的工作.我不想绕过一堆静态方法. …
什么是一个相当现代,设计良好,相当复杂的ASP.NET webforms网站的例子,有源代码可用?特别是使用MVP或MVC模式.
注意:我不是在寻找使用ASP.NET MVC框架的站点.我正在寻找使用传统webforms构建的网站,即使他们恰好使用MVC模式
如果我<Checkbox Content="Text" FlowDirection="RightToLeft">
在复选框的左侧定义文本上传
但是,如果定义<Checkbox Content="Text:" FlowDirection="RightToLeft">注意:符号然后我看到奇怪的效果它不是文本:CheckBox但它的diplsys:文本Chekbox:符号出现一个文本的左侧,它也适用于所有类型的charectes?
有任何想法吗??
我有两个解决方案
我还有两个TFS 2010构建配置
为了防止BuildConfigB尝试部署WebApplication1,我<DeployOnBuild>false</DeployOnBuild>在WebApplication1.csproj中添加了一个.但这也阻止了BuildConfigA部署它.我怎么能适应这种情况?
我已经习惯了using System.Linq;为IEnumerable扩展方法添加,但有时我尝试在类上使用扩展方法并且它没有出现在intellisense中,我花了太多时间试图找出什么是在实现之前我只需要一个Visual Studio没有找到的使用声明.是否有VS2010扩展可以在标准Ctrl+ . View.ShowSmartTag功能中找到扩展方法?
extension-methods visual-studio-2010 visual-studio-extensions
我想使用ExpandoObject作为类型的Razor视图的viewmodel ViewPage<dynamic>.我这样做时出错了
ExpandoObject o = new ExpandoObject();
o.stuff = new { Foo = "bar" };
return View(o);
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使这项工作?
有没有很好的XAML样式的在线资源?免费或付费,无所谓 - 我只是想找到一个相当大的样式集合,我可以放入我的应用程序并尝试不同的外观
编辑:第一次谷歌搜索想出了
http://www.xamltemplates.net/
http://reuxables.com
我已经阅读了SQL Server事务日志,但对如何使用/管理它们仍然不太满意.我知道它们对事务回滚,镜像,复制和日志传送等很重要.
对我来说,它们看起来仍然像一个黑盒子,我对它们做任何事都不太舒服.是否有工具允许我查看事务日志文件或获取有关它的信息?如果我不需要事务日志传送之类的东西,我可以定期收缩和/或截断我的日志文件吗?特别是在将备份还原到测试实例的情况下 - 我真的需要一个占用空间的数GB日志文件吗?我需要注意哪些其他功能特别依赖于事务日志,如果我缩小/截断日志文件将无法工作?
transaction-log sql-server-2008 database-replication database-mirroring
silverlight ×2
wpf ×2
xaml ×2
architecture ×1
asp.net ×1
asp.net-mvc ×1
datatemplate ×1
designer ×1
dynamic ×1
html ×1
jquery ×1
jquery-ui ×1
msdeploy ×1
mvp ×1
mvvm ×1
oop ×1
razor ×1
styles ×1
tfs2010 ×1
tfsbuild ×1
unit-testing ×1