XAML无法识别隐藏代码

时间:2019-07-30 02:33:01

标签: c# visual-studio xaml

我正在尝试将变量“ CalorieGoal”绑定到XAML中的文本块。但是,每当尝试这样做时,都会出现错误“找不到类型“ local:NutritionInfo””和“名称空间“ NutritionInfo”在“ NutrientTracker [程序名]”中不存在。”为什么是这个吗?

我确保我的语法正确。 XAML代码:

  let refiFrame =  useCallback(node => {
    refiFrame = node
  });

C#:

<ContentControl x:Name="ContentRoot">
            <ContentControl.ContentTemplate>
                <DataTemplate x:DataType="local:NutritionInfo">
                    <Grid VerticalAlignment="Bottom" Height="250" Margin="0,450,0,0">
                        <Rectangle Fill="Beige" Stroke="Black" StrokeThickness="3" Width="639" Height="250" Margin="0,0,0,0"/>
                        <TextBlock Text="Goal:" FontSize="18" Margin="7,50,0,0"/>
                        <TextBlock Text="Eaten:" FontSize="18" Margin="7,120,0,0"/>
                        <TextBlock Text="Remaining:" FontSize="18" Margin="7,190,0,0"/>

                        <TextBlock Text="Calories:" FontSize="18" Margin="140,10,0,0"/>
                        <TextBlock Text="Fat(g):" FontSize="18" Margin="270,10,0,0"/>
                        <TextBlock Text="Carbs(g):" FontSize="18" Margin="380,10,0,0"/>
                        <TextBlock Text="Protein(g):" FontSize="18" Margin="520,10,0,0"/>

                        <TextBlock TextAlignment="Center" FontSize="18" Margin="-290,50,0,0" Name="lblCalorieGoal" Text="{Binding }"/>
                    </Grid>
                </DataTemplate>
            </ContentControl.ContentTemplate>
        </ContentControl>

0 个答案:

没有答案