小编Kam*_*cki的帖子

C# WPF 使用 ItemsControl 管理嵌套结构

所以,我已经发布了一个关于 WPF 中嵌套控件结构的问题,它在这里: 嵌套控件结构 - 在 XAML 或 C# 中? 我收到了如下解决方案:

<ItemsControl ItemsSource="{Binding SomeCollectionOfViewModel}">
   <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
         <UniformGrid/>
      </ItemsPanelTemplate>
   </ItemsControl.ItemsPanel>
   <ItemsControl.ItemTemplate>
       <DataTemplate>
          <ItemsControl ItemsSource="{Binding SomeCollection}">   <!-- Nested Content -->
              ...
       </DataTemplate>
   <ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)

我已经使用了那个解决方案,提出了这个:

<!-- The UniformGrids - boxes -->
<ItemsControl ItemsSource="{Binding UniformGridCollection}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>

                <!-- The TextBoxes - Cells -->
                <ItemsControl ItemsSource="{Binding TextBoxCollection}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <UniformGrid />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>

            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
Run Code Online (Sandbox Code Playgroud)

这是 C# 方面:

public partial class MainWindow : Window
    {
        private …
Run Code Online (Sandbox Code Playgroud)

c# wpf grid xaml itemscontrol

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

覆盖函数类型原型

在玩游戏并尝试覆盖Function原型时,我遇到了一个有趣的行为.

我们假设我们像这样重写toString():

const funcToString = Function.prototype.toString;
Function.prototype.toString = function() { 
    console.log("lol"); 
    return funcToString.call(this); 
}
Run Code Online (Sandbox Code Playgroud)

现在,让我们采取行动,看看会发生什么:

(function foo(){}).toString(); // TypeError
Run Code Online (Sandbox Code Playgroud)

TypeError:Function.prototype.toString要求'this'是一个Function

通过一些阅读,我了解到这与内部函数如何将其包装在代理中有关 - 并且它与它的目标无法区分,会导致TypeError.

但现在,我们可以尝试这样做:

function boo(){};
boo.toString(); // prints "lol", as we wanted
Run Code Online (Sandbox Code Playgroud)

为了添加所有这些,我只在浏览器运行时中观察到了这种行为.在Node.js中,两种情况下一切顺利.

编辑:确认在REPL工作没有任何错误.

就个人而言,我无法理解区别是什么/究竟发生了什么.如果有人能够对此有所启发,将不胜感激.

javascript function

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

保证金突然冒出来

在构建页面时,我遇到了一个无法解释的问题:

侧边栏中的第一个div有一个奇怪的突破

在此输入图像描述

第二张图片,显示侧边栏中的顶部div(模板边栏付款)实际上并没有包含该差距.

在此输入图像描述

我有一个边缘出现,没有任何地方设置(我搜索广泛和广泛).

#template-sidebar {
  display: table-cell;
  width: 200px;
  padding-right: 15px;
  height: 626px;
  background: #FFF;
  border-right: 7px solid #fec30d;
}
.sidebar-element {
  height: 200px;
  border-top: 10px solid #ffffff;
  border-bottom: 10px solid #ffffff;
}
.sidebar-element hr {
  border: none;
  height: 1px;
  color: #c6c6c6;
  background-color: #c6c6c6;
  /*border: 0.5px solid #c6c6c6;*/
  box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05);
}
.sidebar-element h4 {
  padding-top: 10px;
}
#template-sidebar-payment {
  border-top: 0;
  !important
}
#template-sidebar-rules {
  border-bottom: 0;
  !important
}
Run Code Online (Sandbox Code Playgroud)
<div id="template-sidebar">
  <div …
Run Code Online (Sandbox Code Playgroud)

html css

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

标签 统计

c# ×1

css ×1

function ×1

grid ×1

html ×1

itemscontrol ×1

javascript ×1

wpf ×1

xaml ×1