首页 \ 问答 \ 对象的孩子(children of object)

对象的孩子(children of object)

我有一个应该返回UIElementCollection的函数。 该函数接受具有children属性的UIElement (即stackpanelgrid等),但不知道它是哪个UIElement ,所以我将它存储到一般对象中。

public UIElementCollection retCol (object givenObject){
...
}

我想返回givenObject的子givenObject ,但除了将givenObject作为stackpanel或grid格式化之外,我找不到这样做的方法。

有没有办法可以获得givenObject的children属性?


I have a function that is supposed to return a UIElementCollection. The function takes in a UIElement that has the children property (i.e. stackpanel, grid, etc.) but does not know which UIElement it is, so I store it into a general object.

public UIElementCollection retCol (object givenObject){
...
}

I want to return the children of the givenObject, but I can't find a way to do so besides casting givenObject as a stackpanel or grid.

Is there a way I can get the children property of the givenObject?


原文:https://stackoverflow.com/questions/14902949
更新时间:2019-12-06 21:27

最满意答案

要转换数据类型,您可以“转换”它(而不是“传递”)。 看到这个链接

ClickMouse(Integer(x + Bmp.Width / 2),Integer(y + Bmp.Height / 2),mbLeft);

当我看到ClickMouse定义时 ,它不仅需要一个Integer ,它还需要一个const Integer来获取它的所有参数:

 procedure ClickMouse(const X, Y: Integer; const Btn: TMouseButton);

根据定义const必须在编译时可评估。 如果我理解正确,那么你采取的方法是行不通的......


Ok, tanks to all. Sertac Akyuz had the solution: change the / for a div to return an integer.

ClickMouse((x + Bmp.Width div 2),(y + Bmp.Height div 2),mbLeft);

The problem was that I can't have a decimal coordinate.

相关问答

更多
  • 平台考虑 这取决于用于浮点计算的平台。 使用x87 FPU时,转换是免费的,因为注册内容是相同的 - 您有时可能支付的唯一价格是内存流量,但在很多情况下甚至没有流量,因为您可以简单地使用该值而不进行任何转换。 x87在这方面实际上是一个奇怪的野兽 - 很难区分浮点和双精度,因为使用的指令和寄存器是相同的,加载/存储指令和计算精度本身是用状态位控制的。 使用混合浮点/双精度计算可能会导致意外的结果(并且由于此原因,编译器命令行选项可以控制精确行为和优化策略)。 当您使用SSE(有时Visual Studio默 ...
  • 来自cppreference std::numeric_limits::is_modulo的true对所有用模运算处理溢出的算术类型T都是true ,也就是说,如果这种类型的加法,减法,乘法或除法的结果超出范围[ min() , max() ],此操作返回的值与期望值的max()-min()+1的倍数不同。 浮点数的溢出是未定义的行为 ,因此float和double std::numeric_limits::is_modulo为false 。 From cppreference The value o ...
  • 要转换数据类型,您可以“转换”它(而不是“传递”)。 看到这个链接 。 ClickMouse(Integer(x + Bmp.Width / 2),Integer(y + Bmp.Height / 2),mbLeft); 当我看到ClickMouse的定义时 ,它不仅需要一个Integer ,它还需要一个const Integer来获取它的所有参数: procedure ClickMouse(const X, Y: Integer; const Btn: TMouseButton); 根据定义 , c ...
  • 这全部由JLS中的二进制数字促销规则指定。 来自http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.6.2 : 当运算符将二进制数字提升应用于一对操作数时,每个操作数必须表示可转换为数字类型的值,以下规则适用,顺序如下: 如果任何操作数是引用类型,则进行拆箱转换(第5.1.8节)。 应用扩展基元转换(第5.1.2节)来转换由以下规则指定的一个或两个操作数: 如果任一操作数的类型为double,则另一个操作数转换为double。 ...
  • JSON解析实际上为您提供了一个NSNumber用于json["percentage"] 。 它会作为一个可选的Any因为字典被声明为[String:Any]并且通过键访问字典值可以提供可选项,因为字典中可能不存在该键。 如果您更改: let testValue: Any? = 23.0 至: let testValue: NSNumber = 23.0 那么最后三行会给你23 ,因为NSNumber可以转换为其他类型(将Objective-C NSNumber桥接到Swift本地数字类型的喜悦)。 T ...
  • 这是因为1.1在二进制浮点上不能完全表示。 但1.5是。 结果, float和double表示将保持略微不同的值1.1 。 当写成二进制浮点时,这正是差异: (float) 1.1 = (0.00011001100110011001101)₂ (double)1.1 = (0.0001100110011001100110011001100110011001100110011010)₂ 因此,当你比较它们(和float版本得到提升)时,它们将不相等。 This is because 1.1 is not e ...
  • sizeof计算为size_t ,而不是int 。 所以%d不合适; 你正在调用未定义的行为。 要正确打印size_t类型的数据,我建议例如printf("%zu\n", sizeof(float)); 等等 sizeof evaluates to a size_t, not an int. So %d is not appropriate; you're invoking undefined behaviour. To correctly print data of type size_t, I sugg ...
  • 在32位平台上,ABI约束使得使用历史浮点寄存器变得更加简单; 因此,编译器将FLT_EVAL_METHOD定义为2.这是你得到的结果: Float 63 Double 63 简而言之,当编译器将FLT_EVAL_METHOD定义为2时,就像在32位虚拟机上的情况一样,浮点表达式和常量将被计算为 long double的精度,无论其类型如何,并且仅对lvalues赋值和显式转换将计算值从long double转换为实际浮点类型。 在表达式1+(tmp=tmp/2)顶层没有这样的构造,因此将加法计算为lon ...
  • 我刚用你的代码测试过。 getValue()实际上返回所选项目的索引(仅当您设置显示的值时)。 所有你需要做的就是解析字符串,你会得到你想要的。 String[] nums = {"1","1.5","2","2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9"}; int index = listeningScorenp.getValue(); String val = nums[index]; float selecte ...
  • 在Java中,数值的默认类型是int。 如果你想要它被认为是长的,它应该以l或L为后缀: long l = 10l; 对于浮点值,默认类型为double。 如果你想要一个浮点数,它应该以f或F为后缀: float f = 10.0f; http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html In Java, the default type for a numeric value is int. If you wan ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)