我ui-router
在我的应用程序中使用了优秀的模块.作为其中的一部分,我使用命名视图来管理我在应用程序中的"动态子导航".
考虑以下:
$urlRouterProvider.otherwise('/person/list');
$stateProvider
.state('person', {
url: '/person',
abstract: true,
})
.state('person.list', {
url: '/list',
views: {
"main@": {
templateUrl: "person.list.html",
controller: 'PersonListController'
}
}
})
.state('person.details', {
url: '/{id}',
views: {
'main@': {
templateUrl: "person.details.html",
controller: 'PersonController'
},
'nav@': {
templateUrl: "person.nav.html",
controller: 'PersonNavController'
}
}
});
Run Code Online (Sandbox Code Playgroud)
当用户首次访问该应用时,会向他们显示一个人员列表.当他们点击某个人时,他们会被带到详细信息页面.很基本的东西.这是标记,如果它有帮助......
<div>
<aside ui-view="nav"></aside>
<div ui-view="main"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
但是,PersonNavController
调用REST服务来获取人员列表,因此在查看人员时,用户可以导航兄弟元素.使用上述方法会导致模板和控制器重新渲染,从而导致每次点击后出现延迟,尽管内容永远不会改变.
有没有办法保持'nav@'
视图加载,只刷新'main@'
视图?
我正在尝试创建一个处理弹出窗体的策略,以便在我的应用程序的任何部分使用.到目前为止,我的理解是我需要UserControl
在MainWindow的根目录中使用一个.这将绑定到自己的ViewModel,它将处理在应用程序中发送的消息.
我正在使用MVVM Light,而且我对这个Messenger
课程还很陌生.
想象一下Master/Details场景,其中一个对象包含在一个列表中ListBox
.选择其中一个项目并单击"编辑"按钮将显示UserControl
覆盖整个屏幕的项目.然后,用户可以编辑所选项目,然后单击"确定"以提交更改.
我想要UserControl
打开它是"通用的",我可以抛出任何(可能是一个ViewModel)...它通过a渲染ViewModel DataTemplate
并处理所有对象的更改.单击"确定"将回调到发送类并像以前一样保留更改.
一些有用的情况是......
任何人都可以提供我如何实现这一点的代码示例吗?
我已经在我的WebAPI应用程序中实现了一个版本控制框架,并且非常希望能够使用Microsoft的新帮助页面扩展.
Microsoft.AspNet.WebApi.HelpPage
很简单,我不知道如何让他们两个一起工作.我有2个项目:
版本控制按预期工作.
我已经尝试在根应用程序上安装HelpPage包,当我浏览到帮助页面时,似乎没有找到任何控制器.在内部,我相信它使用:
Configuration.Services.GetApiExplorer().ApiDescriptions
Run Code Online (Sandbox Code Playgroud)
这没有返回结果,所以我收到一个错误.
任何人都可以协助我让这两个包一起工作吗?
编辑: 在开始时,我不确定这是一个路由问题,但最近的评论似乎暗示.这是我的RouteConfig.cs
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapHttpRoute(
name: "SldExportAliasApi",
routeTemplate: "api/v{version}/sld-export/{id}",
defaults: new { id = RouteParameter.Optional, controller = "Export" }
);
routes.MapHttpRoute(
name: "LinkRoute",
routeTemplate: "api/v{version}/link/{system}/{deployment}/{view}",
defaults: new { controller = "Link" }
);
routes.MapHttpRoute(
name: "DefaultSubParameterApi",
routeTemplate: "api/v{version}/{controller}/{id}/{param}",
defaults: new { id = RouteParameter.Optional, param = RouteParameter.Optional }
);
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/v{version}/{controller}/{action}/{id}",
defaults: new { action = "Index", …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用AngularJS和Google的OAuth2创建一个简单的应用程序进行身份验证.
由于弹出窗口阻塞问题和移动友好性,我决定不使用Google API Client Library for JavaScript.
这使我可以选择在Google上完全重定向到OAuth2端点,并使用access_token将用户重定向回我的应用.
我认为这样可以正常工作.重定向URI将为" http://myapp.com/#/register ",并附加"access_token"查询参数.然后,我将使用access_token并将用户定向到我的应用程序中的其他位置.
这不起作用,因为Google API凭据(http://developers.google.com/console)不喜欢在重定向URI中使用"#".
然后,我试着通过使用来关闭URI中的'#'要求
$locationProvider.html5Mode(true);
Run Code Online (Sandbox Code Playgroud)
这也不起作用,因为我的Angular路线无法识别(在Chrome中)明确浏览到" http://myapp.com/register ".
有关如何实现这一点的任何想法?
我正在尝试使用附加属性来触发UIElement
事件触发时的样式更改.
以下是案例情景:
用户看到a TextBox
,然后聚焦然后解开它.在附加属性的某处,它会注意到这个LostFocus
事件,并设置一个属性(某处?)来表示它HadFocus
.
TextBox上的样式然后知道它应该根据这个HadFocus属性设置不同的样式.
这就是我想象的标记......
<TextBox Behaviors:UIElementBehaviors.ObserveFocus="True">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Behaviors:UIElementBehaviors.HadFocus" Value="True">
<Setter Property="Background" Value="Pink"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一些附加属性的组合来使这个工作,我的最新尝试抛出一个XamlParseException
说明"属性不能在触发器上为空".
public class UIElementBehaviors
{
public static readonly DependencyProperty ObserveFocusProperty =
DependencyProperty.RegisterAttached("ObserveFocus",
typeof (bool),
typeof (UIElementBehaviors),
new UIPropertyMetadata(false, OnObserveFocusChanged));
public static bool GetObserveFocus(DependencyObject obj)
{
return (bool) obj.GetValue(ObserveFocusProperty);
}
public static void SetObserveFocus(DependencyObject obj, bool value)
{
obj.SetValue(ObserveFocusProperty, value);
}
private static void OnObserveFocusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ …
Run Code Online (Sandbox Code Playgroud) 我正在尝试批量复制DataTable
包含以下列的内容:
System.Int32
System.String
使用以下列进入SQL数据库:
int
geometry
谁能建议最好的方法来做到这一点?
一些测试代码,如果它有帮助......
DataTable dataTable = new DataTable();
dataTable.Columns.Add("ID", typeof(Int32));
dataTable.Columns.Add("Geom", typeof(String));
dataTable.Rows.Add(1, "POINT('20,20')");
dataTable.Rows.Add(1, "POINT('40,25')");
dataTable.Rows.Add(1, "POINT('60,30')");
SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(connection);
sqlBulkCopy.DestinationTableName = "MySpatialDataTable";
sqlBulkCopy.WriteToServer(dataTable);
Run Code Online (Sandbox Code Playgroud)
我的原始帖子未能解释执行上述操作会导致抛出以下异常.
InvalidOperationException:数据源中String类型的给定值无法转换为指定目标列的类型udt.
我假设从这里SqlBulkCopy
不知道geometry
列类型,因此不知道如何从a转换为它string
.谁能证实这一点?
我有一个客户端在两个端点上使用以下连接到WCF服务:
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
Run Code Online (Sandbox Code Playgroud)
这适用于我的开发环境(都在本地运行),并且协商正常.当我将它推送到测试环境时,我收到以下消息:
与"SOAP安全协商://主机/ HTTP服务为目标" 的http://主机/服务 "失败.有关详细信息,请参阅内部异常
内在的例外:
System.ComponentModel.Win32Exception:安全支持提供程序接口(SSPI)身份验证失败.服务器可能未在标识为" host/server-name.domain " 的帐户中运行.如果服务器正在服务帐户(例如,网络服务)中运行,请将该帐户的ServicePrincipalName指定为服务器的EndpointAddress中的标识.如果服务器在用户帐户中运行,请将该帐户的UserPrincipalName指定为服务器的EndpointAddress中的标识.
在随机更改属性并且通常搞乱之后,我能够使其工作的唯一方法是更改服务的应用程序池以使用LocalSystem作为标识.这随后导致系统管理员有小猫,而不是我可以继续做的事情.
任何人都可以解释为什么会这样吗?客户端Windows帐户和AppPool的标识都在同一个域中.该服务正在同一域中的服务器上运行.
我不确定我是否正确使用这个,但实际上我正在尝试显示一个分组的项目列表,其中每个项目可以是多个组的成员.即两个实体在多对多的基础上相关.我会试着解释一下......
我的问题是,如何将这样的项目组合成一个控件?我知道ICollectionView和PropertyGroupDescription,但这似乎不符合我的目的(它似乎只适用于一对多的情况).
有任何想法吗?
有些要点需要注意:
我正在尝试根据子实体的集合过滤实体.这是我的实体(EF POCO):
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Order> Orders { get; set; }
}
public class Order
{
public int Id { get; set; }
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
使用Breeze js我想要返回任何Order.Description包含单词'foo'的所有客户.我想象查询看起来像这样:
query = entityQuery.from('Customers')
.where("Orders.Description", "contains", "foo");
Run Code Online (Sandbox Code Playgroud)
但当然这不会奏效.有任何想法吗?
我正在尝试在Button或ContentControl等内容控件更改其内容时触发动画.我最初的想法是这样做:
<ContentControl x:Name="ContentElement">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<ContentPresenter x:Name="Content">
<ContentPresenter.Triggers>
<EventTrigger RoutedEvent="WHATGOESHERE">
<BeginStoryboard Storyboard="{StaticResource MyAnimation}" Storyboard.TargetName="Content"/>
</EventTrigger>
</ContentPresenter.Triggers>
</ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ContentControl.Style>
<Button Content="Hello"/>
</ContentControl>
Run Code Online (Sandbox Code Playgroud)
但我不知道更改/更新ContentPresenter时会触发哪个事件.有任何想法吗?
c# ×7
wpf ×4
.net ×2
angularjs ×2
asp.net-mvc ×1
breeze ×1
google-api ×1
iis ×1
javascript ×1
mvvm ×1
mvvm-light ×1
oauth-2.0 ×1
sql-server ×1
sqlbulkcopy ×1
sqlgeometry ×1
wcf ×1
xaml ×1