【问题标题】:How to bind Image coordinates on Grid如何在网格上绑定图像坐标
【发布时间】:2016-06-29 08:20:18
【问题描述】:

我在网格上有一个图像(名为car1),我想将car1 坐标绑定到textblock。

<Canvas>
    <Image Name="car1" />
</Canvas>

<WrapPanel>
    <TextBlock Text="" Margin="10" Name="xx" Width="50"></TextBlock>
    <TextBlock Text="" Margin="10" Name="yy" Width="50">0</TextBlock>
</WrapPanel>

如何解决?

【问题讨论】:

  • Grid 在哪里?

标签: c# wpf data-binding binding coordinates


【解决方案1】:

试试这个

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Canvas>
            <Image Name="car1" Canvas.Left="40" Canvas.Top="30"/>
        </Canvas>

        <WrapPanel>
            <TextBlock Text="{Binding Path=(Canvas.Left), ElementName=car1}" Margin="10" Name="Left" Width="50"/>
            <TextBlock Text="{Binding Path=(Canvas.Top), ElementName=car1}" Margin="10" Name="Top" Width="50"/>
        </WrapPanel>

    </Grid>
</Window>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-16
    • 2021-11-06
    • 1970-01-01
    相关资源
    最近更新 更多