小编Tat*_*ead的帖子

如何使覆盖控制高于所有其他控件?

我需要让控件出现在所有其他控件之上,因此它将部分覆盖它们.

wpf xaml controls overlay

156
推荐指数
5
解决办法
22万
查看次数

如何将整数传递给ConverterParameter?

我想绑定到一个整数属性:

<RadioButton Content="None"
             IsChecked="{Binding MyProperty,
                         Converter={StaticResource IntToBoolConverter},
                         ConverterParameter=0}" />
Run Code Online (Sandbox Code Playgroud)

我的转换器是:

[ValueConversion(typeof(int), typeof(bool))]
public class IntToBoolConverter : IValueConverter
{
    public object Convert(object value, Type t, object parameter, CultureInfo culture)
    {
        return value.Equals(parameter);
    }

    public object ConvertBack(object value, Type t, object parameter, CultureInfo culture)
    {
        return value.Equals(false) ? DependencyProperty.UnsetValue : parameter;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是,当我的转换器被调用时,参数是字符串.我需要它是一个整数.当然我可以解析字符串,但我必须这样做吗?

感谢konstantin的任何帮助

wpf binding ivalueconverter

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

与基本版本 SES 相比,SESv2 的 aws-sdk 是否缺少某些功能?

我对 SES 和 SESV2 之间 javascript aws-sdk 的差异感到困惑。我的默认假设是 V2 是升级/更新,应该涵盖基本 SES 模块具有的所有功能,但似乎存在很多差距,至少那些处理收据规则集的功能似乎缺失。或者我错过了什么?

例如,“listReceiptRuleSets”位于 aws-sdk SES 中,但不在 SESv2 中。V2中有类似的动作吗?

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#listReceiptRuleSets-property

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SESV2.html

javascript amazon-web-services amazon-ses aws-sdk-js

22
推荐指数
1
解决办法
5683
查看次数

为嵌套属性实现INotifyPropertyChanged

我有一个Person类:

public class Person : INotifyPropertyChanged
{
     private string _name;
     public string Name{
     get { return _name; }
     set {
           if ( _name != value ) {
             _name = value;
             OnPropertyChanged( "Name" );
           }
     }

     private Address _primaryAddress;
     public Address PrimaryAddress {
     get { return _primaryAddress; }
     set {
           if ( _primaryAddress != value ) {
             _primaryAddress = value;
             OnPropertyChanged( "PrimaryAddress" );
           }
     }

     //OnPropertyChanged code goes here
}
Run Code Online (Sandbox Code Playgroud)

我有一个Address类:

public class Address : INotifyPropertyChanged
{
     private string _streetone;
     public …
Run Code Online (Sandbox Code Playgroud)

c# wpf binding mvvm inotifypropertychanged

15
推荐指数
3
解决办法
9547
查看次数

C#OPEN XML:从EXCEL到DATATABLE获取数据时跳过空单元格

任务

从数据导入excelDataTable

问题

将跳过不包含任何数据的单元格,并将具有该行中数据的下一个单元格用作空列的值.例如

A1是空的A2有一个值Tom,然后在导入数据A1得到的值A2A2保持空白

为了说清楚,我在下面提供一些屏幕截图

这是excel数据

在此输入图像描述

这是从excel导入数据后的DataTable 在此输入图像描述

public class ImportExcelOpenXml
{
    public static DataTable Fill_dataTable(string fileName)
    {
        DataTable dt = new DataTable();

        using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(fileName, false))
        {

            WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart;
            IEnumerable<Sheet> sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();
            string relationshipId = sheets.First().Id.Value;
            WorksheetPart worksheetPart = (WorksheetPart)spreadSheetDocument.WorkbookPart.GetPartById(relationshipId);
            Worksheet workSheet = worksheetPart.Worksheet;
            SheetData sheetData = workSheet.GetFirstChild<SheetData>();
            IEnumerable<Row> rows = sheetData.Descendants<Row>();

            foreach (Cell cell in rows.ElementAt(0))
            {
                dt.Columns.Add(GetCellValue(spreadSheetDocument, …
Run Code Online (Sandbox Code Playgroud)

c# datatable openxml spreadsheetml openxml-sdk

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

WPF无边框窗口调整大小

我正在WPF中设计自己的自定义窗口,我一直在尝试实现我以前在WinForms中使用的调整大小功能.由于某种原因,我的WndProc的返回值没有给我正确的结果.

我有一个NativeMethods类用于我所有的WndProc消息和结果:

public class NativeMethods
{
    public const int WM_NCHITTEST  = 0x84;
    public const int HTCAPTION     = 2;
    public const int HTLEFT        = 10;
    public const int HTRIGHT       = 11;
    public const int HTTOP         = 12;
    public const int HTTOPLEFT     = 13;
    public const int HTTOPRIGHT    = 14;
    public const int HTBOTTOM      = 15;
    public const int HTBOTTOMLEFT  = 16;
    public const int HTBOTTOMRIGHT = 17;
}
Run Code Online (Sandbox Code Playgroud)

这是我的窗口背后的代码:

public partial class MainWindow : Window
{
    const int GripSize   = 16; …
Run Code Online (Sandbox Code Playgroud)

.net c# wpf cursor window-resize

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

使用SSIS填充使用OOXML生成的Excel工作簿

我们正在尝试使用OOXML生成MS Excel工作簿并使用SSIS填充数据.我们能够生成工作簿和工作表,还能够在标题单元格中创建列和插入数据.我们还可以使用SSIS填充数据.

但Sheet(DocumentFormat.OpenXml.Spreadsheet.Sheet)和所有单元格(DocumentFormat.OpenXml.Spreadsheet.Cell)成为OpenXmlUnknownElement.因此,我们无法使用以下代码读取工作表/单元格:Sheet sheet = workbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == "Sheet1").SingleOrDefault<Sheet>();

如果我们首先使用MS Excel打开并保存,我们可以读取相同的文件.有谁知道如何解决这个问题?

excel ssis openxml spreadsheetml openxml-sdk

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

Docx或XPS(或一般的ooxml)关系转换示例

好吧,我已经知道有一个关于此的文件,其中说明:

12.2.4.26 Relationships Transform Algorithm
13 The relationships transform takes the XML document from the Relationships part and converts it to another
14 XML document.
15 The package implementer might create relationships XML that contains content from several namespaces, along
16 with versioning instructions as defined in Part 5: “Markup Compatibility and Extensibility”. [O6.11]
17 The relationships transform algorithm is as follows:
18 Step 1: Process versioning instructions
19 1. The package implementer shall process the versioning instructions, considering that …
Run Code Online (Sandbox Code Playgroud)

xml docx xps openxml

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

CloudFormation 在启动 EC2 实例时抛出“参数 groupId 的值 () 无效。该值不能为空”

我想为公共子网中的单个 Linux EC2 实例编写一个完整的 CloudFormation 模板。我使用AWS CloudFormation 模板创建了一个以安全组为起点的 EC2 实例。此模板在您的默认 VPC 中启动一个实例。

我的目标是拥有一个自包含模板,可以在新堆栈中创建所需的所有内容,但不会创建到默认 VPC 中。我想要一个新的 VPC、安全组、路由表、互联网网关、子网并启动一个新的 Linux EC2 实例。

所以我使用了上面的模板并添加了所需的资源并使用Refs链接它们。一切都很好:VPC、子网、安全组、Internet GW、RouteTables 等。但我的 EC2 会出错,堆栈会回滚。

状态原因是:

Value () for parameter groupId is invalid. The value cannot be empty (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterValue; Request ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx)

CloudFormation 模板中的 EC2 资源如下所示:

"EC2Instance" : {
        "Type" : "AWS::EC2::Instance",
        "Properties" : {
          "InstanceType" : { "Ref" : "InstanceType" },
          "SecurityGroups" : [ { "Ref" : …
Run Code Online (Sandbox Code Playgroud)

aws-cloudformation amazon-vpc aws-security-group

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

WPF XAML定义的MenuItem重用开始工作,然后消失

以下简单代码尝试在两个单独的菜单上重用Window.Resources中定义的MenuItem.

<Window x:Class="WpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:collections="clr-namespace:System.Collections;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
    <collections:ArrayList x:Key="menuItemValues">
       <MenuItem Header="First"/>
       <MenuItem Header="Second"/>
       <MenuItem Header="Third"/>
    </collections:ArrayList>
    <MenuItem x:Key="menuItem" x:Shared="False"
              ItemsSource="{StaticResource menuItemValues}"
              Header="Shared menu item"/>
  </Window.Resources>
  <StackPanel>
    <Menu HorizontalAlignment="Left" VerticalAlignment="Top">
      <StaticResource ResourceKey="menuItem"/>
      <StaticResource ResourceKey="menuItem"/>
    </Menu>
  </StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)

这开始很棒,当你第一次选择菜单时,一切看起来都很好.第一个菜单有所需的MenuItems,

在此输入图像描述

第二个也是如此:

在此输入图像描述

但是当您导航回第一个菜单时,MenuItems会消失:

在此输入图像描述

有人可以解释为什么菜单消失,并有办法让这个工作?

这是在调查另一个异常的SO问题时发现的.我尝试使用在另一个SO问题上讨论的策略,它似乎解决了问题,直到你第二次导航回菜单并且它消失了.

我在2台不同的机器上重现了这个问题:

  1. Win 10,VS2013 Ult V12.0.40629.00 Update 5,.NET V4.6.0138
  2. Win 7,VS2013 Prem V12.0.31101.00 Update 4,.NET V4.5.51209

wpf code-reuse xaml menuitem visual-studio-2013

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