我想绑定到一个整数属性:
<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的任何帮助
我对 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
我有一个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) 任务
从数据导入excel
到DataTable
问题
将跳过不包含任何数据的单元格,并将具有该行中数据的下一个单元格用作空列的值.例如
A1是空的A2有一个值Tom
,然后在导入数据A1
得到的值A2和A2保持空白
为了说清楚,我在下面提供一些屏幕截图
这是excel数据
码
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) 我正在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) 我们正在尝试使用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打开并保存,我们可以读取相同的文件.有谁知道如何解决这个问题?
好吧,我已经知道有一个关于此的文件,其中说明:
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) 我想为公共子网中的单个 Linux EC2 实例编写一个完整的 CloudFormation 模板。我使用AWS CloudFormation 模板创建了一个以安全组为起点的 EC2 实例。此模板在您的默认 VPC 中启动一个实例。
我的目标是拥有一个自包含模板,可以在新堆栈中创建所需的所有内容,但不会创建到默认 VPC 中。我想要一个新的 VPC、安全组、路由表、互联网网关、子网并启动一个新的 Linux EC2 实例。
所以我使用了上面的模板并添加了所需的资源并使用Ref
s链接它们。一切都很好: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) 以下简单代码尝试在两个单独的菜单上重用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台不同的机器上重现了这个问题:
wpf ×5
c# ×3
openxml ×3
binding ×2
openxml-sdk ×2
xaml ×2
.net ×1
amazon-ses ×1
amazon-vpc ×1
aws-sdk-js ×1
code-reuse ×1
controls ×1
cursor ×1
datatable ×1
docx ×1
excel ×1
javascript ×1
menuitem ×1
mvvm ×1
overlay ×1
ssis ×1
xml ×1
xps ×1