Я создаю изображения динамически и вставляю значения положения столбца и строки, но он не показывает изображения в xaml.
Мой код:
XAML :
<UserControl x:Class="DesignPanelSimulator.ImageFileTransferView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DesignPanelSimulator"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid Background="Red">
<Grid x:Name="showImages" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
</Grid>
</Grid>
</UserControl>
Делегат активирован и ему удается добраться до функции, и он запускает
, но в xaml я не вижу картинки
в xaml.cs:
public delegate string FilterDelegate();
public ImageFileTransferView()
{
InitializeComponent();
DataContext =new ImageFileTransferViewModel();
ListFromFolderToFileTransferViewModel.sendTheUrlForImage += ShowImage;
}
public void ShowImage(string url)
{
string[] jpegFiles = Directory.GetFiles(url, "*.jpeg");
if (jpegFiles.Length > 0)
{
foreach (var image in jpegFiles)
{
Image ImageViewer = new Image();
Grid.SetRow(showImages, x);
Grid.SetColumn(showImages, y);
string strUri2 = String.Format(image);
ImageViewer.Source = new BitmapImage(new Uri(strUri2));
showImages.Children.Add(ImageViewer);
x += 2;
if (x == 6)
{
x = 0;
y = 2;
}
}
}
}
Спасибо