【问题标题】:How to get image source path from another Binding image source path by clicking on binding image如何通过单击绑定图像从另一个绑定图像源路径获取图像源路径
【发布时间】:2014-11-17 18:25:36
【问题描述】:

我已经在列表框中绑定了一些图像,当我将点击一个绑定图像时,该图像将通过来自绑定图像源的源设置在主图像中。

这是我想从绑定数据中显示图像的代码。

<Grid x:Name="Icon" Margin="134,51,173,556">        
    <Image x:Name="MyIconImage" HorizontalAlignment="Left" Height="90" Width="93" Source="" />
</Grid>

这是我绑定数据的代码

<Grid Margin="0,366,0,0">
    <ListBox x:Name="List"
               ItemsSource="{Binding ListItemSource}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <Image x:Name="IconListImage" Source="{Binding IconPath}" Width="48" Height="48" Tap="IconListImage_Tap"/>
                    <TextBlock x:Name="appName" Text="{Binding AppName}"/>
                    <TextBlock Text="{Binding IconPath}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</Grid>

【问题讨论】:

    标签: c# xaml windows-phone-8 data-binding windows-phone-8.1


    【解决方案1】:

    您尝试过 SelectedValuePath 吗?

    <Image x:Name="MyIconImage" HorizontalAlignment="Left" Height="90" Width="93" Source="{Binding ElementName=List, Path=SelectedValue}" />
    
    <ListBox x:Name="List" ItemsSource="{Binding ListItemSource}" SelectedValuePath="IconPath">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel>
                    <Image x:Name="IconListImage" Source="{Binding IconPath}" Width="48" Height="48" Tap="IconListImage_Tap"/>
                    <TextBlock x:Name="appName" Text="{Binding AppName}"/>
                    <TextBlock Text="{Binding IconPath}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-30
      • 1970-01-01
      • 2016-12-07
      • 2017-09-06
      • 1970-01-01
      相关资源
      最近更新 更多