小编Enz*_*ojz的帖子

WPF Template.FindName返回始终为null

模板

<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)

c# wpf xaml findname

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

为什么编译器总是希望这种类型一次(=)重载?

我有一个问题,我从三天起就不明白,因为我不明白,我无法解决.

我有这样的代码:

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)

ocaml

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

为什么在构建OCaml和OCaml代码时总是需要C编译器环境?

这是我头脑中的一个问题,我在Windows下使用OCaml,当我构建每个OCaml发行版本时,我需要一个C编译器,MSVC或MingGW,我必须在Cygwin下完成.

当我手头有我的OCaml,当我需要编译我的代码时,我还需要用于编译我的OCaml的c链接器.对我来说这很奇怪.为什么OCaml不能使用较旧版本的OCaml而不是某些C编译器自动引导?

ocaml compilation

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

标签 统计

ocaml ×2

c# ×1

compilation ×1

findname ×1

wpf ×1

xaml ×1