我安装了VS2008和VS2010,我看到了一个非常奇怪的行为
在VS2008中,我有一个简单的WPF应用程序:
<TextBox x:Name="textbox" Text="{Binding Path=MyProperty,Mode=TwoWay}"></TextBox>
Run Code Online (Sandbox Code Playgroud)
和
public Window1()
{
InitializeComponent();
DataContext = this;
}
public string MyProperty
{
get { return (string)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register("MyProperty", typeof(string), typeof(Window1), new PropertyMetadata("default",null,Coerce));
private static object Coerce(DependencyObject d, object baseValue)
{
return "Coerced Value";
}
Run Code Online (Sandbox Code Playgroud)
当我在文本框中输入随机字符串并点击标签时,我希望textbox.Text重置为"Coerced Value".如果我调试我看到应用程序在Coerce功能中断,但UI没有更新.
有趣的是,这个相同的代码在VS2010中工作,UI使用Coerced值进行更新.任何人都有想法发生了什么?
它是WPF错误吗?还是我错过了什么?
我正在使用IL来抛出一个Int32并捕获它.这只是出于好奇,我不想做任何事情,所以请不要告诉我抛出异常而不是int.
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 40 (0x28)
.maxstack 2
.locals init (object V_0,
int32 V_1)
IL_0000: nop
.try
{
IL_0001: nop
IL_0002: ldsfld int32 ConsoleApplication3.Program::i
IL_0007: throw
} // end .try
catch [mscorlib]System.Object
{
IL_0008: stloc.0
IL_0009: nop
IL_000a: ldstr "In Object catch"
IL_000f: call void [mscorlib]System.Console::WriteLine(string)
IL_0014: nop
IL_0015: ldloc.0
IL_0016: unbox.any [mscorlib]System.Int32
IL_001b: stloc.1
IL_001c: ldloc.1
IL_001d: call void [mscorlib]System.Console::WriteLine(int32)
IL_0022: nop
IL_0023: nop
IL_0024: leave.s IL_0026
} …Run Code Online (Sandbox Code Playgroud) 我想使用ico文件中的第4张图片:C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary\1033\VS2008ImageLibrary\VS2008ImageLibrary\Objects\ico_format\WinVista\Hard_Drive.ico
如果我使用Windows Photo Viewer看到此图标,则会显示13个不同的图标.
我已将此ico转储到资源文件中,如何使用索引检索所需的图标.
我正在使用Directory.Exists(uncPath)UNC路径,现在如果我使用标准IPv6地址则失败.是否有代码可以处理所有格式的unc - ipv4/ipv6/machiname.
目前我将我的ipv6地址转换为类似的东西2001-0-234-c1ab-0-a0-aabc-3e.ipv6-literal.net并且它可以工作,但是Ipv6本身可以用多种格式表示.我需要能处理所有格式的东西.
我想要的只是我的消息框应该在其标题栏中显示我的应用程序的图标(或任何其他图标),但它没有,为什么不呢?
我有一个 WPF 文本框,并执行以下操作
哪个 event/eventargs 可以告诉我在位置 4 处输入了 0。我需要在预览级别知道这一点,以便我可以根据前缀和后缀数字拒绝字符 0。