相关疑难解决方法(0)

如何分析在Linux上运行的C++代码?

我有一个在Linux上运行的C++应用程序,我正在优化它.如何确定代码的哪些区域运行缓慢?

c++ unix profiling

1732
推荐指数
12
解决办法
49万
查看次数

为什么WPF Style在ToolTip中显示验证错误为TextBox工作但对ComboBox失败?

我使用一个典型的样式来显示验证错误作为IErrorDataInfo的工具提示,如下所示,它可以正常工作.

    <Style TargetType="{x:Type TextBox}">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                Value="{Binding RelativeSource={RelativeSource Self},
            Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

但是当我尝试为这样的ComboBox做同样的事情时,它失败了

    <Style TargetType="{x:Type ComboBox}">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                Value="{Binding RelativeSource={RelativeSource Self},
            Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

我在输出窗口中得到的错误是:

System.Windows.Data错误:17:无法从'(Validation.Errors)'获取'Item []'值(类型'ValidationError')(类型'ReadOnlyObservableCollection`1').BindingExpression:路径=(0)[0] .ErrorContent; DataItem ='ComboBox'(Name ='ownerComboBox'); target元素是'ComboBox'(Name ='ownerComboBox'); target属性是'ToolTip'(类型'Object')ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException:指定的参数超出了有效值的范围.参数名称:index'

奇怪的是,如果我更改任何ComboBox值,它也会尝试在关闭窗口时进行无效的数据库更改(这也是发生绑定错误时)!

无法将值NULL插入列'EmpFirstName',表'OITaskManager.dbo.Employees'; 列不允许空值.INSERT失败.该语句已终止.

简单地通过评论风格完美的每一个作品.我该如何解决?

万一有人需要它,其中一个comboBox'xaml如下:

<ComboBox ItemsSource="{Binding Path=Employees}" 
                  SelectedValuePath="EmpID"                       
                  SelectedValue="{Binding Path=SelectedIssue.Employee2.EmpID,
                     Mode=OneWay, ValidatesOnDataErrors=True}" 
                  ItemTemplate="{StaticResource LastNameFirstComboBoxTemplate}"
                  Height="28" Name="ownerComboBox" Width="120" Margin="2" 
                  SelectionChanged="ownerComboBox_SelectionChanged" />


<DataTemplate x:Key="LastNameFirstComboBoxTemplate">
    <TextBlock> 
         <TextBlock.Text> 
             <MultiBinding StringFormat="{}{1}, {0}" > 
                   <Binding Path="EmpFirstName" /> 
                   <Binding Path="EmpLastName" /> 
             </MultiBinding> …
Run Code Online (Sandbox Code Playgroud)

c# data-binding validation wpf styles

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

WPF在.NET Framework 4.0中的启动速度很慢

我注意到如果我为任何CPU/x64构建我的WPF应用程序,启动(大约20秒)或加载新控件需要花费的时间比在x86上启动(在发布和调试模式下) ,在VS的内部或外部.甚至最简单的WPF应用程序也会出现这种情况.在这个MSDN线程中讨论了这个问题,但没有提供答案.这只发生在.NET 4.0中 - 在3.5 SP1中,x64与x86一样快.有趣的是,微软似乎知道这个问题,因为VS2010中新的WPF项目的默认值是x86.

这是一个真正的错误还是我做错了?

编辑:可能与此相关:C#.NET 4.0中的慢速数据绑定设置时间.我正在大量使用数据绑定.

.net wpf performance 64-bit .net-4.0

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

标签 统计

wpf ×2

.net ×1

.net-4.0 ×1

64-bit ×1

c# ×1

c++ ×1

data-binding ×1

performance ×1

profiling ×1

styles ×1

unix ×1

validation ×1