X: snap is not tied to attached property

Can anyone hear how this is done right? I get a compiler error in the generated code.

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

(this is just a minimal example, without Mode=OneWayit obviously works, but I need it ... Also, I would like to do it with a {x:Bind}non-traditional one {Binding})

+4
source share
2 answers

Bind item name:

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

You can report it on Visual Studio connect .

I think you can think about it by calling this.Bindings.Update()when you change the line and save x: bind OneTime.

, Grid.Row "BlueRect" , , .

XAML:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="100"/>
        <RowDefinition Height="*"/>
    </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)}" Fill="Red" />
    <Button Content="Click me" Grid.Row="3" Click="Button_Click"></Button>
</Grid>

:

private void Button_Click(object sender, RoutedEventArgs e)
{
    Grid.SetRow(BlueRect, 2);
    this.Bindings.Update();
}

this.Bindings.Update() , async, x: bind.

0

Source: https://habr.com/ru/post/1615746/


All Articles