Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.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# 访问ItemTemplate Silverlight中的模板化列表框_C#_Xaml_Templates_Mvvm_Silverlight 5.0 - Fatal编程技术网

C# 访问ItemTemplate Silverlight中的模板化列表框

C# 访问ItemTemplate Silverlight中的模板化列表框,c#,xaml,templates,mvvm,silverlight-5.0,C#,Xaml,Templates,Mvvm,Silverlight 5.0,我正在silverlight中创建一个模板控件,它基本上是一个列表框,列表框中的每个项目都有一个组合框 我试图将combobox选项作为依赖项属性存储在主控件中,然后访问每个项上的控件以将combobox的ItemsSource绑定到此依赖项属性,但我似乎无法获得正确的绑定,无论是查看单个项还是主窗口视图模型。下面是我目前拥有的 控制 好的,现在解决了,需要将ListBox的DataContext绑定到模板化的父对象 DataContext="{Binding RelativeSource={R

我正在silverlight中创建一个模板控件,它基本上是一个列表框,列表框中的每个项目都有一个组合框

我试图将combobox选项作为依赖项属性存储在主控件中,然后访问每个项上的控件以将combobox的ItemsSource绑定到此依赖项属性,但我似乎无法获得正确的绑定,无论是查看单个项还是主窗口视图模型。下面是我目前拥有的

控制


好的,现在解决了,需要将ListBox的DataContext绑定到模板化的父对象

DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
然后combobox项源的相对源绑定工作

ItemsSource="{Binding DataContext.DropDownOptions, RelativeSource={RelativeSource AncestorType=telerik:RadListBox}}"
ItemsSource="{Binding DataContext.DropDownOptions, ElementName=GroupList}"

ItemsSource="{Binding DataContext.DropDownOptions, RelativeSource={RelativeSource AncestorType=telerik:RadListBox}}"

ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
ItemsSource="{Binding DataContext.DropDownOptions, RelativeSource={RelativeSource AncestorType=telerik:RadListBox}}"