0

我对 Silverlight/Telerik 比较陌生,我如何将它正在寻找的资源从新添加的“LayoutRoot”网格传递到最初的顶级“UserControl.Resources”。

谢谢,我很感谢您提前提供任何帮助:)

<controls:ViewBase x:Class="CS.MyProgram.Silverlight.Module.Viewer.LoanTradingPnLDashboard.LoanTradingPnLViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:CS.MyProgram.Library.Controls.Data;assembly=Library.Controls" 
xmlns:controls="clr-namespace:CS.MyProgram.Silverlight.Library.Controls;assembly=Library"
xmlns:libraryData="clr-namespace:CS.MyProgram.Library.Controls.Data;assembly=Library.Controls"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
xmlns:telerikControl="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:navigate="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
xmlns:Controls1="clr-namespace:CS.MyProgram.Library.Controls;assembly=Library.Controls" 
xmlns:Controls2="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
xmlns:asp="clr-namespace:System.Reflection.Emit;assembly=mscorlib" 
xmlns:Converters="clr-namespace:CS.MyProgram.Silverlight.Module.Viewer.LoanTradingDashboard.Converters;assembly=Viewer" 
xmlns:GenericComponents="clr-namespace:CS.MyProgram.Silverlight.ComponentLibraries.GenericComponents;assembly=GenericComponents" 
xmlns:Command="clr-namespace:CS.MyProgram.Silverlight.ComponentLibraries.GenericComponents.Command;assembly=GenericComponents"
xmlns:vcharting="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"
xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView">

<Grid x:Name="LayoutRoot" >

    <Grid.RowDefinitions>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

    <UserControl.Resources> <!-- !!!!!! This Line Has The Ambiguous Reference -->
        <!--STUFF LIKE THIS-->
        <telerikControl:Office_BlackTheme x:Key="Theme"/>
        <telerikControl:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <!--STUFF LIKE THIS-->
    </UserControl.Resources>

    <Grid x:Name="AnotherGrid" >
        <!--STUFF LIKE THIS-->
        <telerik:CustomDataGrid />
        <!--STUFF LIKE THIS-->
    </Grid>

</Grid>
4

1 回答 1

0

我无法重现任何“不明确的参考”错误。我收到的 XAML 错误如下:

在“用户控件”类型中找不到可附加属性“资源”。

具有名称的元素可以表示属于该类<Something.SomethingElse>的名称的附加属性(例如,),或者它可以引用该类的(非附加)依赖属性,前提是该元素是元素的直接子元素SomethingElseSomethingGrid.RowSomethingElseSomething <Something>

在这种情况下,因为<UserControl.Resources>element 不是元素的直接子<UserControl>元素(它是 a 的直接子元素<Grid>),Silverlight 会查找以ResourcesUserControl类型命名的附加属性,但不存在此类附加属性。

解决这个问题非常简单:更改UserControl.ResourcesGrid.Resources

    <Grid.Resources>
        <!--STUFF LIKE THIS-->
        <telerikControl:Office_BlackTheme x:Key="Theme"/>
        <telerikControl:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <!--STUFF LIKE THIS-->
    </Grid.Resources>

该属性是由和许多其他类型从Resources继承的Grid,因此它不仅仅属于s。如果您愿意,您实际上可以将它放在顶级元素下。如果这样做,则必须将其命名为,因为它是元素的直接子元素。UserControlFrameworkElement.ResourcesUserControl<controls:ViewBase><controls:ViewBase.Resources><controls:ViewBase>

于 2013-08-07T19:23:22.603 回答