小编nia*_*iao的帖子

WPF ListBox滚动到自动结束

在我的申请中,我有一个ListBox项目.该应用程序是用WPF编写的.

如何自动滚动到最后添加的项目?我希望在ScrollViewer添加新项目时将其移动到列表的末尾.

有什么事ItemsChanged吗?(我不想使用这个SelectionChanged活动)

wpf scroll listbox

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

添加到textblock wpf的超链接

问候,我在db中有一些文本,它如下:

Lorem ipsum dolor坐下来,精致的adipistur elit.Duis tellus nisl,venenatis et pharetra ac,tempor sed sapien.整齐的pellentesque blandit velit,在tempus urna semper坐下来.Duis mollis,libero ut consectetur interdum,massa tellus posuere nisi,eu aliquet elit lacus nec erat.赞美商品.**[a href =' http ://somesite.com']某个网站[/ a]**在新西兰的Suspendisse坐在amet massa molestie gravida feugiat ac sem.Phasellus ac mauris ipsum,vel auctor odio

我的问题是:我怎样才能显示Hyperlink一个TextBlock?我不想为此目的使用webBrowser控件.我不想使用此控件之一:http://www.codeproject.com/KB/WPF/htmltextblock.aspx

html wpf textblock hyperlink

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

css border-left 50%height

我希望我的div的左边框只显示div的一半.我想对我的右边界做同样的事情,但是应该从div的底部到div的中间设置.我怎样才能实现它?

css border

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

wpf平面按钮

如何在wpf中制作按钮平面样式?我已经尝试过BasedOn属性,但它不起作用.

wpf button flat

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

Invoke和BeginInvoke

问候,我正在用C#开发一些应用程序.目前我正在处理线程,我有一个问题,我在脑海里.Invoke和BeginInvoke有什么区别?我读了一些帖子,我在这里找到了一些有用的信息:这里

但是,以下代码中的Invoke和BeginInvoke之间有什么区别:

private void ProcessRoutine()
{
   for (int nValue = StartFrom; nValue <= EndTo; nValue++)
   {
      this.Invoke(this.MyDelegate, nValue);
      //this.BeginInvoke(this.MyDelegate, nValue);
   }
   MessageBox.Show("Counting complete!");
}
private void MessageHandler(int progress)
{
    lblStatus.Text = lblStatus.Text = "Processing item: " + progress.ToString();
    progressBar1.Value = progress;
}
Run Code Online (Sandbox Code Playgroud)

其中MyDelegate是对MessageHandler函数的引用.

我注意到使用BeginInvoke lblStatus.Text没有刷新,使用Invoke刷新标签.另外我知道Invoke等待它的执行完成.我感兴趣的最重要的案例是为什么在这种情况下刷新标签文本会有所不同.

c# asynchronous invoke begininvoke

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

ChannelFactory Credentials +对象是只读的

问候,当我尝试为我的工厂设置凭证时,问题是:

ChannelFactory<IWCFSeekService> factory = Factory;
if (factory != null)
{
    factory.Credentials.UserName.UserName = CServiceCredentials.Instance.Username;
    _Channel = factory.CreateChannel();
}
Run Code Online (Sandbox Code Playgroud)

我得到一个异常,即对象是只读的.当我想设置用户名时会发生这种情况.

wcf credentials channelfactory

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

安装WindowsXP更新后WCF服务错误

问候,

今天在我开始处理我的应用程序之前,我更新了我的WinXP.安装完所有更新后,我的WCF服务停止工作.当我尝试在浏览器中打开service.svc文件时出现以下错误:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/bindings: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error: 


Line 131:       </behaviors>
Line 132:
Line 133:       <bindings>
Line 134:           <wsHttpBinding>
Line 135:               <binding name="MyWSHttpBinding" maxReceivedMessageSize="2147483647">
Run Code Online (Sandbox Code Playgroud)

我的同事试图在更新之前运行相同的服务,它工作正常.安装更新后,他遇到了同样的问题.有人可以帮帮我吗?

wcf windows-update

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

jstree选择节点

问候,我正在使用jsTree来生成我的分层数据.JsTree生成如下:

$(function() {
$("#industries").tree({
        data: {
            type: "json",
            opts: {
                url: "/Admin/GetIndustries/"
            }
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

它的工作原理和jsonresult是这样的:

[{"attributes":[],"data":{"title":"Adwokaci, Notariusze","id":"1a051101-c3fa-48f2-b2e1-c60d1b67ea22"},"children":[{"attributes":[],"data":{"title":"Kancelarie adwokackie","id":"26d6cff1-3c7f-4a2f-bf5a-422e08127b43"
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何在某些隐藏字段中保存所选节点的ID?我做这样的事情:

<script type="text/javascript">
    $("#industries").click(function() {
        var tree = $.tree.reference("industries");
        var t = $.tree.focused(); if (t.selected) t.selected; else alert("Select a node first");
        alert(t.id);

    });
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我进入警报窗口"未定义".有人可以帮帮我吗?

编辑: 我已经更改了jstree实例,如下所示:

$(function() {
$("#industries").tree({
        callback: {
            onselect: function(NODE, TREE_OBJ) {
                    alert(NODE.id);
                }
            },
        data: {
            type: "json",
            opts: {
                url: "/Admin/GetIndustries/"
            }
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我得到空洞的警觉

jquery jstree

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

我应该使用WPF转换器还是触发器?

我想知道你如何决定何时使用converters以及何时使用triggers.我更喜欢在GUI上使用触发器来操作(比如显示/隐藏控件,改变它们的外观等).

前段时间我使用了一个BooleanToVisibilityConverter用于此目的,但现在,我只是不需要它,我做所有与visibility使用触发器相关的事情,我甚至开始思考" 由MS团队创建一个目的是什么BooleanToVisibilityConverter?" .通常,当我有可能尝试使用声明方式编写代码时 - 在本例中 - XAML.

你对此有何看法?

.net wpf xaml triggers converter

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

Windows身份验证-特殊用户需要其他密码

我正在开发一个Intranet asp.net核心Web API应用程序。身份验证的要求是:

  • REQ1-当试图访问该网站的用户不在Active Directory的特殊组中(让其命名为“ commonUsers”)时,它根本没有被授权
  • REQ2-当尝试访问该网站的用户位于Active Directory的组“ commonUsers”中时,将被授权并返回Web资源
  • REQ3-当试图访问该网站的用户位于Active Directory的“ superUser”组中时,需要再次提示其输入域密码(因为它试图访问一些非常受限的资源)

现在,我到目前为止:

  • 我的服务使用http.sys服务器托管,以支持Windows身份验证。
  • 我正在使用Claims Middlewere来检查用户的Active Directory组,让我们说这样的话:

    public class ClaimsTransformer : IClaimsTransformation {
    private readonly IAuthorizationService _authorizationService;
    public ClaimsTransformer(IAuthorizationService authorizationService)
    {
        _authorizationService = authorizationService;
    }
    
    public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
    {
        _authorizationService.Authorize(principal as  IHmiClaimsPrincipal);
        return Task.FromResult(principal);
    }}
    
    Run Code Online (Sandbox Code Playgroud)
  • 我还在服务配置中指定了特殊策略,例如:

    services.AddAuthorization(options =>
        {
            options.AddPolicy(“ TestPolicy”,策略=> 
                                       policy.RequireClaim(ClaimTypes.Role,“ TestUser”));
            options.AddPolicy(“ TestPolicy2”,策略=> 
                                       policy.RequireClaim(ClaimTypes.Role,“ SuperUser”));
        });
  • 我将 [Authorize]属性与特定策略结合使用,以便基于策略限制对特定资源的访问

现在的问题是,我应该如何满足REQ3?

c# windows-authentication asp.net-core

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