Image 使用.png绑定Silverlight图像无效
我在论坛上仔细检查了这一点,但没有找到解决办法 这非常有效:Image 使用.png绑定Silverlight图像无效,image,binding,png,silverlight-5.0,Image,Binding,Png,Silverlight 5.0,我在论坛上仔细检查了这一点,但没有找到解决办法 这非常有效: <Image Margin="0,0,0,0" Stretch="UniformToFill" Source="http://localhost:5313/Images/1.png" MaxHeight="140" MinHeight="155" VerticalAlignment="Top"/> 主页 控制 ItemsSource=“{Binding FilteredTemperatureReports}”U
<Image Margin="0,0,0,0" Stretch="UniformToFill" Source="http://localhost:5313/Images/1.png" MaxHeight="140" MinHeight="155" VerticalAlignment="Top"/>
主页
控制
ItemsSource=“{Binding FilteredTemperatureReports}”UseLayoutRounding=“False”
RowHeight=“20”HorizontalAlignment=“Stretch”VerticalAlignment=“Stretch”SelectionMode=“Single”
水平网格线brush=“透明”垂直网格线brush=“透明”
Background=“{x:Null}”BorderBrush=“{x:Null}”
IsFilteringAllowed=“False”RowIndicatorVisibility=“折叠”
CanUserColumns=“False”ShowGroupPanel=“False”
HeaderRowStyle=“{StaticResource GridViewHeaderRowStyle}”
GroupRowStyle=“{StaticResource GridViewGroupRowStyle}”
RowStyle=“{StaticResource GridViewRowStyle}”>
什么不好
Thnaks该
{Binding}
不会自动知道在哪里找到imageselectrocionada
您需要将其链接到特定元素,通常是命名用户控件:
<UserControl x:Name="ThisCtrl" .... >
<Image Source="{Binding ImagenSeleccionada, ElementName=ThisCtrl}" ... />
(或者,您可以在代码隐藏构造函数中将DataContext
设置为this
)
或者,您可以将图像绑定的相对源设置为用户控件的祖先,最好通过其类型:
<UserControl ...>
<Image Source="{Binding ImagenSeleccionada,
RelativeSource={RelativeSource AncestorType=local:YourUserControlType}}" ... />
Hi。还是不行,我能给你看些什么,因为可以得到传统的帮助。谢谢Charles.如果您在构造函数中进行组件初始化后分配ImagenSelectionada
,我相信这些更改只有在您使用时才会被UI接受。我建议您将常规属性替换为相应的依赖属性。Mr。古斯塔夫松。谢谢,但是这个案子。你会用什么?我将编辑以显示其他代码信息。
<telerik:GridViewDataColumn Width="150" DataMemberBinding="{Binding Medio}" IsReadOnly="True" Header="Medio"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyleFirst}"
CellStyle="{StaticResource GridViewCellStyle}" />
<telerik:GridViewDataColumn Width="80" DataMemberBinding="{Binding TimeStamp}" IsReadOnly="True" Header="Fecha" DataFormatString="{} {0:dd/MM/yyyy}"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}"/>
<telerik:GridViewDataColumn Width="200" DataMemberBinding="{Binding Producto}" IsReadOnly="True" Header="Producto"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}"/>
<telerik:GridViewDataColumn Width="180" DataMemberBinding="{Binding Version}" IsReadOnly="True" Header="Version"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}"/>
<telerik:GridViewDataColumn Width="80" DataMemberBinding="{Binding Inversion}" IsReadOnly="True" Header="Inversion" DataFormatString="{}{0:C}"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}"/>
<telerik:GridViewDataColumn Width="80" DataMemberBinding="{Binding Ytd}" IsReadOnly="True" Header="YTD" DataFormatString="{}{0:C}"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}"/>
<telerik:GridViewColumn Width="80" IsReadOnly="True" Header="Product"
HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}"
CellStyle="{StaticResource GridViewCellStyle}" >
void OnGridViewSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
{
var grid = sender as RadGridView;
if (grid.SelectedItem != null)
{
grid.ScrollIntoView(grid.SelectedItem);
var _internetDataViewModel = this.DataContext as InternetDataViewModel;
_internetDataViewModel.ImagenSeleccionada = ((ExecutiveDashboard.TemperatureData)(grid.SelectedItem)).Image;
}
}
<UserControl x:Name="ThisCtrl" .... >
<Image Source="{Binding ImagenSeleccionada, ElementName=ThisCtrl}" ... />
<UserControl DataContext="{Binding RelativeSource={RelativeSource Self}}" ... >
<Image Source="{Binding ImagenSeleccionada}" ... />
<UserControl ...>
<Image Source="{Binding ImagenSeleccionada,
RelativeSource={RelativeSource AncestorType=local:YourUserControlType}}" ... />