找不到类型“类型”。[行:7 位置:21]
我正在尝试动态生成数据模板。它工作正常,但如果我包含这个属性,我会得到上述异常。
Width="{Binding Path=ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewCell}}}"
以及完整的方法:
public DataTemplate GetTextColumnTemplate(int index)
{
string templateValue = @"
<DataTemplate
xmlns:sys=""clr-namespace:System;assembly=mscorlib""
xmlns:telerik=""http://schemas.telerik.com/2008/xaml/presentation""
xmlns=""http://schemas.microsoft.com/client/2007""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<StackPanel>
<TextBox Width=""{Binding Path=ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewCell}}}"" Text=""{Binding Path=V" + (index + 1).ToString() + @",Mode=TwoWay}"" AcceptsTab=""True"" AcceptsReturn=""True""/>
</StackPanel>
</DataTemplate>";
return (DataTemplate)XamlReader.Load(templateValue);
}