1
無法在查找對象上設置圖像源Uri。 Stackpanel包含兩個孩子文本框和圖像控件。無法在Silverlight 4中設置圖像源
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
{
var textBox = (TextBox)sender;
textBox.Style = Application.Current.Resources["TextBoxNormal"] as Style;
textBox.FontSize = 15;
textBox.Foreground = new SolidColorBrush(Colors.Gray);
var stackpanel = textBox.Parent as StackPanel;
if (stackpanel == null)return;
var img = stackpanel.Children.Where(a => a is Image).FirstOrDefault();
if (textBox.Text != "")
{
//I was trying set Uri as mention below, but there is Nothing like "Image.Source"
//image.Source = new BitmapImage(new Uri("/Images/Others/TickRight.png", UriKind.RelativeOrAbsolute));
}
變種IMG = stackpanel.Children.Where(A => a是圖片).FirstOrDefault()作爲圖像; – Faizan 2011-12-19 17:28:36