我有具有圖像一個用戶控件和一個正文塊,像這樣:結合在用戶控件
<Image Stretch="UniformToFill" Source="{Binding Path=ImageURL}"/>
<TextBlock Text="{Binding Path=Title}"/>
在用戶控制的的.cs
我有相關性屬性,使結合:
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(MyUserControl), null);
public string ImageURL
{
get { return (string)GetValue(ImageURLProperty); }
set { SetValue(ImageURLProperty, value); }
}
public static readonly DependencyProperty ImageURLProperty =
DependencyProperty.Register("ImageURL", typeof(string), typeof(MyUserControl), null);
public MyUserControl()
{
this.InitializeComponent();
(this.Content as FrameworkElement).DataContext = this;
}
在我的MainPage.xaml中我把它叫做一個列表裏面
<ListView Grid.Row="1"
HorizontalAlignment="Center"
Name="ControlsListView">
<ListView.ItemTemplate>
<DataTemplate>
<controls:MyUserControl Margin="20"
Title="{Binding Title}" //works
ImageURL="{Binding ImageURL}"/> //doesn't work
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
然後,我從Json.net得到這個數據,並將其輸送給它ListView的emsSource。它只適用於標題,但不適用於ImageURL,任何人都可以幫助我爲什麼?
其實這最後還是挺好的。問題是我正在測試一個電話,這個特定的手機有一個問題,沒有渲染圖像從網上喂(耶)。 –
這裏有什麼程序?我應該刪除這個問題嗎? –