Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF将未知数量的字符串传递给用户控件_C#_Wpf_Xaml_User Controls - Fatal编程技术网

C# WPF将未知数量的字符串传递给用户控件

C# WPF将未知数量的字符串传递给用户控件,c#,wpf,xaml,user-controls,C#,Wpf,Xaml,User Controls,好的,我有一个用户控件,它有一个图像url属性 public static readonly DependencyProperty ImageUrlProperty = DependencyProperty.Register("ImageUrl", typeof(string), typeof(CoreGameTile)); public string ImageUrl { get { return (string)GetValue(ImageUrlPro

好的,我有一个用户控件,它有一个图像url属性

public static readonly DependencyProperty ImageUrlProperty = DependencyProperty.Register("ImageUrl", typeof(string), typeof(CoreGameTile));
public string ImageUrl
        {
            get { return (string)GetValue(ImageUrlProperty); }
            set { SetValue(ImageUrlProperty, value); }
        }
现在我如何在不知道确切数字的情况下传递多个图像URL呢

因此,有时我会有5个图像URL,其他时候我可能有2个左右。在不知道确切数量的情况下传递多个图像URL的方法是什么

我还希望能够使用XAML像这样添加它

<Controls:CoreGameTile Width="200" Height="100" Margin="2" Title="Bink" ImageUrl="http://www.splashdamage.com/screens_brink/031.jpg"/>

也许您可以将
图像URL
列表传递给它,您可以使用
foreach
循环来设置列表中的每个
图像URL

public string ImageUrl
{
    get { return (List<string>)GetValue(ImageUrlProperty); }
    set
    {
        foreach (ImageUrl url in value)
        {
            SetValue(ImageUrlProperty, url);
        }
    }
}
公共字符串ImageUrl
{
get{return(List)GetValue(ImageUrlProperty);}
设置
{
foreach(值为ImageUrl的url)
{
SetValue(ImageUrlProperty,url);
}
}
}

Agree的可能副本。将
typeof(字符串)
更改为
typeof(列表)