小编Arc*_*rus的帖子

如何告诉调试器忽略抛出抛出的异常?

我有一个TextBox,我在其中使用第三方库验证输入.但是,当语法不正确时,此库会引发自定义异常.除了调试时,这不是什么大问题.

在调试时,由于TextBox中的文本始终是错误的(我还在键入它),调试器将在每个字母后停止,直到它正确,这真的很烦人,因为我验证每个字母.

如何告诉调试器不要破坏这些自定义异常?

PS我已经尝试过滤Debug - > Exceptions(添加它Common Language Runtime Exceptions),但这对我不起作用.调试器仍然在调用库的行停止.

PPS使用Visual Studio 2010.

对于非信徒

回答:

最后我和我的PS非常接近.这是一个非常愚蠢的错误:我在命名空间中输入了一个拼写错误.感谢Pop Catalin和Madhur Ahuja指出它!

c# debugging exception visual-studio-2010

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

WPF:我如何处理ListBox项目的点击?

在我的WPF应用程序中,我正在处理ListBox SelectionChanged事件,它运行正常.

现在我需要处理一个点击事件(即使对于已经选择的项目); 我尝试过MouseDown,但它不起作用.如何处理ListBox单击项目?

c# wpf listboxitem

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

数据绑定到WPF中的UserControl

我有一个UserControl,我想参与数据绑定.我在用户控件中设置了依赖项属性,但无法使其工作.

当我用静态文本(例如BlueText ="ABC")调用它时,uc显示正确的文本.当我尝试将它绑定到本地公共属性时,它始终是空白的.

<src:BlueTextBox BlueText="Feeling blue" />            <!--OK-->
<src:BlueTextBox BlueText="{Binding Path=MyString}" /> <!--UserControl always BLANK!-->
<TextBox Text="{Binding Path=MyString}" Width="100"/>  <!--Simple TextBox Binds OK-->
Run Code Online (Sandbox Code Playgroud)

我已将代码简化为以下简化示例.这是UserControl的XAML:

    <UserControl x:Class="Binding2.BlueTextBox" ...
    <Grid>
        <TextBox x:Name="myTextBox" Text="{Binding BlueText}" Foreground="Blue" Width="100" Height="26" />
    </Grid>
Run Code Online (Sandbox Code Playgroud)

以下是UserControl背后的代码:

public partial class BlueTextBox : UserControl
{
    public BlueTextBox()
    {
        InitializeComponent(); 
        DataContext = this; // shouldn't do this - see solution
    }

    public static readonly DependencyProperty BlueTextProperty =
        DependencyProperty.Register("BlueText", typeof(string), typeof(BlueTextBox));

    public string BlueText
    {
        get { return GetValue(BlueTextProperty).ToString(); }
        set { …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml wpf-controls

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

在HTML5中拉伸iframe

我有两个html文件,一个包含另一个iframe,我想让这个iframe延伸到父html的整个高度.

所以第一个html文件(有一个红色背景)看起来像:

<!DOCTYPE html>
<html>
<body style="background-color: red; margin: 0px; padding: 0px;">
    <iframe src="Blue.html" frameborder="0" scrolling="no"  height="100%" width="100%" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

第二个(有蓝色背景):

<!DOCTYPE html>
<html>    
<body style="background-color: blue;" />
</html>
Run Code Online (Sandbox Code Playgroud)

如果所有事情都是正确的,我希望只能看到蓝色背景,因为iframe应该与整个父页面重叠,但我只看到一条蓝色条纹和一大堆红色..

使用HTML5 doctype <!DOCTYPE html>我似乎无法获得正确的结果:

使用HTML5 DOCTYPE

如果我删除HTML5文档类型,我会得到我想要的结果.我认为这是因为它将以怪癖模式呈现HTML:

没有HTML5 DOCTYPE

我确实想要HTML文档类型,所以我该如何解决这个问题呢?谢谢你的期待!

iframe html5 doctype

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

在C#中创建一个空的BitmapSource

在c#中创建空(0x0 px或1x1 px和完全透明)BitmapSource实例的最快(几行代码和低资源使用)方法是什么,当没有任何应该呈现时使用.

c# wpf bitmapsource

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

为什么我的WPF Datagrid不显示数据?

演练说您可以在一行中创建WPF数据网格,但不提供完整的示例.

所以我创建了一个使用通用列表并将其连接到WPF数据网格的示例,但它没有显示任何数据.

我需要更改下面的代码才能让它在datagrid中显示数据?

回答:

此代码现在有效:

XAML:

<Window x:Class="TestDatagrid345.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:local="clr-namespace:TestDatagrid345"
    Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
    <StackPanel>
        <toolkit:DataGrid ItemsSource="{Binding}"/>
    </StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

代码背后:

using System.Collections.Generic;
using System.Windows;

namespace TestDatagrid345
{
    public partial class Window1 : Window
    {
        private List<Customer> _customers = new List<Customer>();
        public List<Customer> Customers { get { return _customers; }}

        public Window1()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = Customers;

            Customers.Add(new Customer { FirstName = "Tom", LastName = "Jones" });
            Customers.Add(new Customer …
Run Code Online (Sandbox Code Playgroud)

c# wpf datagrid

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

菜单项打开和关闭事件

每当菜单项的子菜单打开时,我想处理一个事件.关闭也是如此.我怎样才能做到这一点?

c# wpf event-handling wpf-controls menuitem

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

在控制器中拥有包罗万象的请求映射排除资源

我有一个默认的 spring mvc 应用程序。在其中,我有一个像这样的控制器:

@GetMapping("/**")
public String get(Model model) { }
Run Code Online (Sandbox Code Playgroud)

现在这适用于所有请求,所以这很好,但它也适用于 js、img、css 文件等静态资源。

如何排除这些资源?顺便说一句,我正在使用注释..

到目前为止我已经尝试过:

网络配置:

  @Override
  public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    super.addResourceHandlers(registry);
    registry.addResourceHandler("/images/**").addResourceLocations("/images/");
    registry.addResourceHandler("/css/**").addResourceLocations("/WEB-INF/css/");
    registry.addResourceHandler("/js/**").addResourceLocations("/js/");
  }

  @Override
  public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
  }
Run Code Online (Sandbox Code Playgroud)

网络初始化器:

public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

  @Override
  protected Class<?>[] getRootConfigClasses() {
    return new Class[]{WebConfig.class};
  }

  @Override
  protected Class<?>[] getServletConfigClasses() {
    return new Class[]{WebConfig.class};
  }

  @Override
  protected String[] getServletMappings() {
    return new String[]{"/"};
  }
Run Code Online (Sandbox Code Playgroud)

但它不起作用,对css文件的请求将由控制器处理,而不是向我显示静态资源。

由于我没有使用 Spring boot,因此链接问题中提到的解决方案并没有为我解决这个问题。

java resources spring controller

7
推荐指数
0
解决办法
1055
查看次数

TypeScript 的可选泛型类型和相应参数

我有以下带有通用参数的 React 功能组件:

type Props<T, S> = {
  data: T[]
  additionalData: S
}

function Component<T, S = void>({
 ....
 
Run Code Online (Sandbox Code Playgroud)

您可以按如下方式使用它:

<Component<Bike, BikeShed> data={bikes} additionalData={bikeShed} />
Run Code Online (Sandbox Code Playgroud)

由于第二个通用参数是可选的,因此您必须按如下方式使用它:

<Component<Car> data={cars} additionalData={undefined} />
Run Code Online (Sandbox Code Playgroud)

现在问题来了。有没有办法省略,additionalData={undefined}因为这里显然没有使用它。

我尝试的是这样的:

type Props<T, S = void> = {
  data: T[]
  additionalData?: S
}
Run Code Online (Sandbox Code Playgroud)

但它实际上改变了SS | undefined这不是一个理想的情况!

Props当可选通用参数为 时,我可以以不必指定其相关属性的方式设置吗void

generics typescript reactjs

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

WPF - 从System.Windows.Application继承

我想拥有自己的继承自System.Windows.Application的应用程序类.问题是在Application.xaml文件中,我必须像这样声明应用程序:

    <src:MyBaseApplication x:Class="MyApplication"
    xmlns:src="clr-namespace:MyApplication;assembly=WpfTestApplication"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="FPrincipal.xaml">    
    <Application.Resources>

    </Application.Resources>
</src:MyBaseApplication>
Run Code Online (Sandbox Code Playgroud)

它在运行时运行良好,但是当我编辑项目属性时,我收到Visual Studio的项目属性编辑器的以下错误消息:

尝试加载此项目的应用程序定义文件时发生错误.无法解析文件'[...]\Application.xaml'.请在XAML编辑器中编辑该文件以修复错误.无法在应用程序定义文件中找到预期的根元素"Application".

该项目是一个VB.NET项目.有人有解决方法吗?我想保留application.xaml文件.

谢谢

.net c# wpf xaml visual-studio-2008

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