小编Luk*_*uke的帖子

WPF TreeView清除选择

如何在WPF TreeView中清除TreeView选项?我已经尝试循环TreeNodes并清除IsSelected属性,但这是一个ReadOnly属性.有任何想法吗?

TreeView是使用XML通过绑定XMLDataProvider对象.

.net wpf treeview

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

如何在Mac OS X上的NSTextField中启用拼写检查?

我有一个NSTextField,我想启用"as-you-type"拼写检查.当我加载我的应用程序时,我可以从菜单栏>编辑>拼写和语法>键入时检查拼写.

我希望默认情况下启用此选项.在IB中我可以为NSTextView启用它,但我想在这部分UI中使用NSTextField.

谢谢.

更新: 有没有人知道是否可以以编程方式运行菜单栏>编辑>拼写和语法>从Objective-C代码在NSTextField上键入选项时检查拼写?似乎NSTextField支持"在键入时检查拼写"选项,只是没有办法从Obj-C启用该选项.

编辑#1

我尝试以下手动启用菜单,但它不起作用:

// Focus TextField
[textField becomeFirstResponder];

// Enable Spell Checking
NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
NSMenu *editMenu = [[mainMenu itemWithTitle:@"Edit"] submenu];
NSMenu *spellingMenu = [[editMenu itemWithTitle:@"Spelling and Grammar"] submenu];
NSMenuItem *autoSpellingMenuItem = [spellingMenu itemWithTitle:@"Check Spelling While Typing"];
[autoSpellingMenuItem setEnabled:YES];

NSLog(@"Menu: %@", [autoSpellingMenuItem description]);
NSLog(@"Target: %@", [[autoSpellingMenuItem target] description]);

// Actually perform menu action
[[autoSpellingMenuItem target] performSelector:[autoSpellingMenuItem action]];
Run Code Online (Sandbox Code Playgroud)

是不是可以直接调用菜单项操作而不是使用setEnabled:YES?

以上输出如下,不确定目标为空的原因

App[3895:a0f] Menu: <NSMenuItem: 0x100135180 Check Spelling While Typing>
Current language:  auto; currently objective-c
App[3895:a0f] …
Run Code Online (Sandbox Code Playgroud)

macos cocoa spell-checking objective-c nstextfield

9
推荐指数
1
解决办法
4500
查看次数

.NET 4.0 WPF自动化异常

我有一个在.NET 3.5 SP1中运行良好的项目.现在升级到.NET 4.0时,我发生了自动化异常.

我在整个项目中搜索了与自动化相关的任何内容,与自动化无关.此外,谷歌搜索无法确认这是否是一个错误.该错误仅发生在少数PC上,并且随机发生.可以完全禁用自动化,因为我认为它可能是.NET 4.0的错误?

Exception Source: PresentationCore
Message: Object reference not set to an instance of an object.
Stack Trace:
   at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, …
Run Code Online (Sandbox Code Playgroud)

.net wpf automation exception

8
推荐指数
1
解决办法
5200
查看次数

VB.NET谓词数组查找

如何使用Array.Find将以下内容转换为VB.NET谓词?

Private Function FindCulture(ByVal Code As String) As Globalization.CultureInfo
    '
    Dim AllCultures As Globalization.CultureInfo() = Globalization.CultureInfo.GetCultures(Globalization.CultureTypes.AllCultures)
    '
    For Each Culture As Globalization.CultureInfo In AllCultures
        If Culture.TwoLetterISOLanguageName = Code Then
            Return Culture
        End If
    Next
    '
    Return Nothing
    '
End Function
Run Code Online (Sandbox Code Playgroud)

vb.net arrays predicate find

7
推荐指数
1
解决办法
6117
查看次数

WPF ListView虚拟化分组

有没有人知道在启用分组时支持UI虚拟化的ListView实现?默认情况下,在设置分组时禁用VirtualizingStackPanel.

看来微软不打算在.NET Framework的v4.0中实现这一点,所以我正在寻找替代解决方案.

.net wpf virtualization performance listview

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

我可以在ASP.NET中使用X509Certificate2而不使用证书存储吗?

我试图在Rackspace Cloud中的ASP.NET Web服务中使用X509Certificate.我有一种感觉,云节点上的证书存储可能会导致问题.我也有一个与此相关的问题,除了我在SslStream.AuthenticateAsClient上接收使用iPhone Apple推送通知提供程序(apns-sharp)时的异常C#

在apns-sharp项目中,我使用以下代码:

certificate = new X509Certificate2(p12File)
Run Code Online (Sandbox Code Playgroud)

但是我收到了一个异常并将代码更改为以下解决了X509Certificate2异常.新代码如下:

certificate = new X509Certificate2(p12File, String.Empty, X509KeyStorageFlags.MachineKeySet);
Run Code Online (Sandbox Code Playgroud)

我想知道我是否可以在ASP.NET中使用X509Certificate2而不使用证书存储?证书存储是否会导致Rackspace Cloud节点出现问题?

更新#1 Rackspace告诉我不允许访问本地机器证书商店.有没有其他方法可以绕过使用证书存储区?也许使用第三方图书馆?

c# asp.net x509certificate2 apns-sharp

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

如何复制WPF FlowDocument InlineUIContainer内容?

我有一个WPF FlowDocument,它有一些InlineUIContainers,这些是简单的InlineUIContainers,它包含一个样式按钮,Button.Content中有一些文本.当我将包含FlowDocument按钮的文本和InlineUIContainer复制到TextBox时,不会复制该按钮.

可以以某种方式转换内联按钮或将按钮转换为粘贴的文本数据中的文本.我已经尝试过使用FlowDocument.DataObject.Copying事件,但我似乎找不到任何关于如何使用它的好样本,或者即使这是正确的方向.

谢谢

wpf flowdocument inlineuicontainer

6
推荐指数
1
解决办法
5254
查看次数

如何在PHP中找到UTF-8字符串中的字节数?

我从php.net站点有以下函数来确定ASCII和UTF-8字符串中的字节数:

<?php 
/** 
 * Count the number of bytes of a given string. 
 * Input string is expected to be ASCII or UTF-8 encoded. 
 * Warning: the function doesn't return the number of chars 
 * in the string, but the number of bytes. 
 * 
 * @param string $str The string to compute number of bytes 
 * 
 * @return The length in bytes of the given string. 
 */ 
function strBytes($str) 
{ 
  // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 …
Run Code Online (Sandbox Code Playgroud)

php string byte utf-8 strlen

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

如何在Objective-C中创建首选项窗口?

我想在标准的Mac OS X应用程序(Safari等)中创建一个首选项窗口.我在2008年找到了与Apple HIG相匹配的DBPrefsWindowController等资源.

只是想知道是否有新方法可以实现这一目标?我无法在Interface Builder中找到任何标准窗口,因此我假设Apple不提供这些窗口,也无法找到用于提供此标准UI的官方Apple示例代码.

谢谢

macos cocoa objective-c

6
推荐指数
1
解决办法
2819
查看次数

WP7 ListBox分组

ListBoxes或其他UI控件是否有任何内置分组?我想有一个列表,但有一些形式的分组或部分应用于列表.如下所示:

heading one
     list item one
     list item two
heading two
     list item one
     list item two
     list item three
     list item four
Run Code Online (Sandbox Code Playgroud)

如果没有从头开始构建某些东西,有什么可用于此目的吗?我不希望混合匹配多个ListBoxes,而是我更喜欢在数据绑定级别处理它的解决方案.

grouping listbox windows-phone-7

5
推荐指数
2
解决办法
5095
查看次数