我有以下(非常简单)ItemsControl:
<ItemsControl Name="BlahList" ItemsSource="{Binding Blah}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Name="MyCheckBox" Content="{Binding Text}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
在代码中,我想做以下事情:
foreach (var dahCurrentItem in BlahList.Items)
{
var ItemCheckBox = BlahList.GimmeMyControl(dahCurrentItem, "MyCheckBox")
// I'm going to do something with the check box here...
}
Run Code Online (Sandbox Code Playgroud)
我怎么做?
我没有使用对话框,我正在使用我已经注册的自定义类,然后使用该CreateWindow调用来创建它,我在注册时将背景颜色预设为红色:
WNDCLASSEX wc;
wc.hbrBackground = CreateSolidBrush(RGB(255, 0, 0));
Run Code Online (Sandbox Code Playgroud)
但现在我想在运行时更改背景颜色,例如单击按钮将其更改为蓝色.
我曾尝试使用SetBkColor()call WM_PAINT,并尝试从WM_CTLCOLORDLG消息中返回一个画笔,它们不起作用.
有帮助吗?
我有一个代码
string code = "AABBDDCCRRFF";
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我想只检索不同的字符
输出应该像:
ANS: ABDCRF
Run Code Online (Sandbox Code Playgroud) 我impersonate在Asp.net 4.0网站的web.config中使用标签.
下面是我的Web.Config代码:
<system.web>
<authentication mode="Windows">
<identity impersonate="true"
userName="Administrator"
password="LALLA$26526"/>
</authentication>
</system.web>
Run Code Online (Sandbox Code Playgroud)
当我在Visual Studio中运行应用程序时,我收到此错误:
Parser Error Message: Unrecognized element 'identity'.
Run Code Online (Sandbox Code Playgroud)
来源错误:
Line 50: <system.web>
Line 51: <authentication mode="Windows">
Line 52: <identity impersonate="true"
Line 53: userName="Administrator"
Line 54: password="LALLA$26526"/>
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
我有一个简单的Restful服务从控制台应用程序调用,所以我使用WebClient.我想知道这次删除是否正确.
该URL看起来像localhost/RestService1/Person/1
using (var client = new WebClient())
{
client.UploadString(url, "DELETE", "");
}
Run Code Online (Sandbox Code Playgroud)
我不喜欢UploadString没有数据参数的重载.传递一个空参数并不适合我.有没有更好的方法用于"删除"?
我可以使用WebRequest,但我想只使用WebClient来保持一致.
这是WebRequest块
var request = WebRequest.Create(url);
request.Method = "DELETE";
var response = (HttpWebResponse)request.GetResponse();
Run Code Online (Sandbox Code Playgroud)
两个块都工作正常,但最好的是什么?或者,还有更好的方法?
我会经常使用此代码来比较字符串:
if(!string.IsNullOrEmpty(str1) && str1.Equals(str2)){
//they are equal, do my thing
}
Run Code Online (Sandbox Code Playgroud)
这首先处理null case等.
有没有更简洁的方法来进行字符串比较,可能只有一个方法调用可以处理可能的空值?我只是想知道如果测试值为null则字符串不相等.
(我有dejavu,我之前可能已经问过这个问题,如果是这样,我道歉)
更新:在我的情况下,str2是一个已知的好字符串,因此我不需要将其检查为null.str1是"未知"字符串,可能为null,所以我想在str1 为空的情况下说"str1不等于str2" ...
在我的VS.NET 2015开发机器上,使用nameof操作符的Razor视图就像魅力一样.
部署到Windows服务器时,无法编译CSHTML Razor视图:
名称"nameof"在当前上下文中不存在.
在德国:
Der Name'nameof'ist im aktuellen Kontext nicht vorhanden.
我安装了.NET Framework 4.6("ASP.NET版本:4.6.81.0")但没有成功.
很可能我错过了一些简单的东西.
不过,我真的很无能为力.它是web.config设置吗?或者是其他东西?
我的问题:
如何nameof在CSHTML Razor视图中启用C#6功能(如运营商)?
我最近开始使用C#,我曾经想在C#中轻松完成一些我想要实现的东西.
例如,我有一个像这样的功能:
def my_func():
return "Do some awesome stuff"
Run Code Online (Sandbox Code Playgroud)
还有一本字典:
my_dic = {"do": my_func}
Run Code Online (Sandbox Code Playgroud)
我制作了一个脚本,当用户输入"do"时,程序会my_func根据字典调用.
我想知道如何将函数分配给C#字典中的字符串.
有没有办法在R Markdown文档中为单个块提供代码折叠,而不是其他(不编写自定义JavaScript)?
我知道我可以使用code_foldingYAML选项,但这适用于整个文档.我想为单个块启用它,但不是所有块.
[原因是编写一个实验室,其中包含不应隐藏的说明,但有问题显示/隐藏解决方案.]
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
Run Code Online (Sandbox Code Playgroud)
这是我的System Web.config文件的程序集
c# ×5
.net ×2
asp.net ×2
api ×1
asp.net-mvc ×1
c#-6.0 ×1
c++ ×1
dictionary ×1
equality ×1
itemscontrol ×1
knitr ×1
null ×1
r ×1
r-markdown ×1
razor ×1
string ×1
web-config ×1
webclient ×1
winapi ×1
wpf ×1