以下面的窗口布局为例:Grid定义了一个元素。它有 3 行。每一行都有一个 Button 元素。如何获取RowDefinition它所属的 Button的对象?谢谢。
注意:通过调用Grid.GetRow(Button element),我获得了Grid.Row该 Button 元素的属性。我不需要那个——而是我需要实际的RowDefinition对象。
我在网格内有 2 行,因为第一行具有固定大小。我正在尝试在这里应用该OnIdiom功能。尝试如下:
<Grid.RowDefinitions>
<RowDefinition>
<RowDefinition.Height>
<OnIdiom x:TypeArguments="x:Double">
<OnIdiom.Phone>30</OnIdiom.Phone>
<OnIdiom.Tablet>60</OnIdiom.Tablet>
</OnIdiom>
</RowDefinition.Height>
</RowDefinition>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
Run Code Online (Sandbox Code Playgroud)
但在错误列表中出现以下错误:
No property, bindable property, or event found for 'Height', or mismatching type between value and property.
Run Code Online (Sandbox Code Playgroud)
RowDefinition 高度 OnIdiom 属性的正确格式是什么?