gpt4 book ai didi

c# - x :Bind not binding to attached property

转载 作者:行者123 更新时间:2023-11-30 12:57:35 26 4
gpt4 key购买 nike

有人能说说这是如何正确完成的吗?我在后面生成的代码中遇到编译器错误。

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="100"/>
</Grid.RowDefinitions>
<Rectangle x:Name="BlueRect" Width="100" Height="100" Grid.Row="1" Fill="Blue" />
<Rectangle Width="100" Height="100" Grid.Row="{x:Bind BlueRect.(Grid.Row),Mode=OneWay}" Fill="Red" />
</Grid>

(这只是一个最小的例子,没有 Mode=OneWay 它显然可以工作,但我需要那个......另外,我想用 {x 来做这个: Bind不是传统的{Binding})

最佳答案

使用元素名称绑定(bind):

<Rectangle Width="100" Height="100" Grid.Row="{Binding ElementName=BlueRect,Path=(Grid.Row),Mode=OneWay}" Fill="Red" />

关于c# - x :Bind not binding to attached property,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33691726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com