小编Jim*_*Jim的帖子

DataGrid计算列

我正在尝试将我的Excel应用程序转移到WPF数据网格.我要将数据输入到A列,并且在BI列中想要计算A柱的当前单元格和当前单元格,并添加B列previus单元格.计算示例:B2 = B1 +(A2-A1).这样做的最佳方法是什么?

c# wpf datagridview

5
推荐指数
1
解决办法
3568
查看次数

VSTO Excel 加载项 - WPF XAML 样式问题

我正在创建 VSTO Office Excel-Add-In,其中弹出一个简单的 WPF 窗口。该窗口采用 MahApps 库设计。问题是,无论我使用哪种方法,图标在 Visual Studio 预览中显示良好,但在调试期间它们会丢失。负责显示图标的 Icons.xaml 安装在 Resources 文件夹中,Build 操作设置为 Page。关于这个问题有什么想法吗?

<Controls:MetroWindow.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
            <ResourceDictionary Source="pack://application:,,,/ExcelAddIn;component/Resources/Icons.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Controls:MetroWindow.Resources>
Run Code Online (Sandbox Code Playgroud)

我也尝试过,但没有成功:

<ResourceDictionary Source="/ExcelAddIn;component/Resources/Icons.xaml" />

<ResourceDictionary Source="pack://application:,,,/component/Resources/Icons.xaml" />
Run Code Online (Sandbox Code Playgroud)

c# wpf excel xaml

5
推荐指数
0
解决办法
467
查看次数

错误TypeError:_v.context.$ implicit.toggle不是函数

我正在使用下面的代码在angular4中测试一个简单的递归Treeview组件.但每当我试图扩大儿童观点时toggle().

我收到一个异常错误:

错误TypeError:_v.context.$ implicit.toggle不是函数

谢谢

树view.component.ts

export class TreeViewComponent implements OnInit {  
  constructor() { }
  ngOnInit() {}     
  @Input() directories: Directory[];
}
Run Code Online (Sandbox Code Playgroud)

树view.component.html

<ul>
  <li *ngFor="let dir of directories">
    <label (click)="dir.toggle()"> {{ dir.title }}</label>
    <div *ngIf="dir.expanded">
      <tree-view [locations]="dir.children"></tree-view>
    </div>
  </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

Directory.ts

 export class Directory{

      title: string;
      children: Directory[]
      expanded = true;
      checked = false;

  constructor() {

  }

  toggle() {
    this.expanded = !this.expanded;
  }

  getIcon() {
    if (this.expanded) {
      return '-';
    }
    return '+';
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular angular5

4
推荐指数
1
解决办法
4928
查看次数

WPF窗口ShowDialog()导致无法设置可见性或调用显示

我正在创建一个wpf表单,用于从datagrid添加/编辑数据.但是,当我检查ShowDialog() == true我得到上述异常时.

代码取自一本书(Windows Presentation Foundation 4.5 Cookbook).

UserWindow usrw = new UserWindow();
usrw.ShowDialog();
if (usrw.ShowDialog() == true)
{
     //do some stuff here;               
}
Run Code Online (Sandbox Code Playgroud)

在WPF窗口上:

private void btn_Save_Click(object sender, RoutedEventArgs e)
{
   DialogResult = true;
   Close();
}
Run Code Online (Sandbox Code Playgroud)

我怎么能处理这个?

===============================

解决这个问题的方法就是删除usrw.ShowDialog(); 它开始按预期工作

UserWindow usrw = new UserWindow();
//usrw.ShowDialog();
if (usrw.ShowDialog() == true)
{
     //do some stuff here;               
}
Run Code Online (Sandbox Code Playgroud)

c# wpf wpf-controls

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

异步任务暂停循环恢复

我有一个示例代码,取自MSDN,我想在while循环中实现Pause/Resume功能.任何人都可以提出一个解决这个问题的解决方案/ parern吗?

 private async void startButton_Click(object sender, RoutedEventArgs e)
    {
        resultsTextBox.Clear();

        // Instantiate the CancellationTokenSource.
        cts = new CancellationTokenSource();

        try
        {
            await AccessTheWebAsync(cts.Token);
            resultsTextBox.Text += "\r\nDownloads complete.";
        }
        catch (OperationCanceledException)
        {
            resultsTextBox.Text += "\r\nDownloads canceled.\r\n";
        }
        catch (Exception)
        {
            resultsTextBox.Text += "\r\nDownloads failed.\r\n";
        }

        cts = null;
    }


    private void cancelButton_Click(object sender, RoutedEventArgs e)
    {
        if (cts != null)
        {
            cts.Cancel();
        }
    }


    async Task AccessTheWebAsync(CancellationToken ct)
    {
        HttpClient client = new HttpClient();

        // Make a list of web addresses. …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library async-await

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

正则表达式解析C#源代码

我正在为以下C#源创建简单的文档映射.

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }

    public string DoSomething(string x)
    {
        return "Hello " + x;
    }
}
Run Code Online (Sandbox Code Playgroud)

结果应以树形视图或列表视图的形式呈现,方式如下:

Person
-- Name
-- Age
-- DoSomething()
Run Code Online (Sandbox Code Playgroud)

所以,问题是,是否有正则表达式或库来处理C#源代码?

c# regex parsing

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

EF Core 3.1 无法映射属性“Geometry.UserData”

我有一个数据库优先的 .net core 3.1 Web 应用程序,它通过一geography列连接到 SQL Server 数据库表。数据库脚手架和应用程序构建完成没有任何问题,但是当我运行应用程序时出现错误。如果我添加该[NotMapped]属性,错误就会消失,但显然该属性未映射。可能是什么问题?

无法映射属性“Geometry.UserData”,因为它属于“object”类型,它不是受支持的基本类型或有效的实体类型。显式映射此属性,或使用 '[NotMapped]' 属性或使用 'OnModelCreating' 中的 'EntityTypeBuilder.Ignore' 忽略它。”

我已经安装了这些软件包

  • Microsoft.EntityFrameworkCore.SqlServer v3.1.8
  • NetTopologySuite.Core v1.15.3

脚手架类看起来像这样

public class MyClass
{  
    public int Id { get; set; }  
    public string Name { get; set; }  
    public NetTopologySuite.Geometries.Geometry Location { get; set; }  
}  
Run Code Online (Sandbox Code Playgroud)

c# entity-framework spatial entity-framework-core

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

AvalonEdit TextView 滚动

我正在尝试使在后面的代码中定义的特定可见行(例如 line152)成为 TextView 上的第一条可见行。另外,我希望突出显示这一行。到目前为止,我已经实施了以下解决方案,没有缺乏:

textEditor.ScrollTo(myLine, 0); // Setting the current line Visible (e.g. line152) in TextView
int firstLine = textEditor.TextArea.TextView.GetDocumentLineByVisualTop(textEditor.TextArea.TextView.ScrollOffset.Y).LineNumber; // This is actual top visible line of current TextView ((e.g. line130) 

textEditor.ScrollTo(firstLine - myLine, 0); //Which is not working
Run Code Online (Sandbox Code Playgroud)

为了突出显示这一行,我发现了一个 Draw() 函数,但不确定如何调用它:

 public void Draw(TextView textView, DrawingContext drawingContext)
    {
        textView.EnsureVisualLines();
        var line = textEditor.Document.GetLineByOffset(textEditor.CaretOffset);
        var segment = new TextSegment { StartOffset = line.Offset, EndOffset = line.EndOffset };

        foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, segment))
        {
            drawingContext.DrawRoundedRectangle(
                new SolidColorBrush(Color.FromArgb(20, 0xff, 0xff, …
Run Code Online (Sandbox Code Playgroud)

c# wpf avalonedit

0
推荐指数
1
解决办法
1931
查看次数

在 Azure 上托管的 React 应用程序中,URL 不适用于刷新

我刚刚注意到,在我的反应应用程序中,当用户刷新页面时,网址不起作用。奇怪的是,本地一切正常。我已经使用 create-react-app 创建了该应用程序。我正在阅读React-router url 在刷新或手动写入时不起作用,但由于构建过程是通过 github 操作自动运行的,因此不清楚如何解决这个问题。谁能建议一个快速的解决方案?

azure reactjs

0
推荐指数
1
解决办法
3611
查看次数