模板
<Style TargetType="{x:Type local:Viewport}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Viewport}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Canvas x:Name="PART_Canvas" IsItemsHost="True"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
和OnApplyTemplate中的代码
content = this.Template.FindName("PART_Canvas", this) as FrameworkElement;
Run Code Online (Sandbox Code Playgroud)
内容返回总是null,为什么它不起作用?
如果我替换为此,程序将直接退出
content = this.ItemsPanel.FindName("PART_Canvas", this) as FrameworkElement;
Run Code Online (Sandbox Code Playgroud) 我有一个问题,我从三天起就不明白,因为我不明白,我无法解决.
我有这样的代码:
module SpotLocation = struct
type t = {
uuid : string option;
netElement : string;
coordIntrinsic : float;
}
end
module Segment = struct
type t ={
netElement : string;
coordFrom : SpotLocation.t;
coordTo : SpotLocation.t;
}
let isEqual segA segB = segA.coordFrom = segB.coordFrom && segA.coordTo = segB.coordTo
let (=) = isEqual (* <<<<<<<<< Here is the problem *)
let isIn seg loc = (seg.netElement = loc.netElement)
end
Run Code Online (Sandbox Code Playgroud)
问题来自(=)我已经超载.
一旦我拥有它,编译器坚持有以下反应:
Error: This expression has type string but …Run Code Online (Sandbox Code Playgroud) 这是我头脑中的一个问题,我在Windows下使用OCaml,当我构建每个OCaml发行版本时,我需要一个C编译器,MSVC或MingGW,我必须在Cygwin下完成.
当我手头有我的OCaml,当我需要编译我的代码时,我还需要用于编译我的OCaml的c链接器.对我来说这很奇怪.为什么OCaml不能使用较旧版本的OCaml而不是某些C编译器自动引导?