简体   繁体   中英

Getting Error in Xaml while Binding data with Converter

I am getting an "Invalid XAML" error while Binding data with a Converter. See this screenshot:

在这里出错

This is my Xaml code:

<DataTemplate>
                        <Border BorderBrush="#cbc6c0"
                                BorderThickness="3"
                                CornerRadius="3"
                                Background="#FFF9F6F4">
                            <Grid Margin="5">
                                <ContentControl Content="{Binding   Converter={StaticResource Groupdetails}}" />
                            </Grid>
                        </Border>
                    </DataTemplate>

... and the C# code for my converter:

public class ListDetailsConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        Model_Detail ObjDetail = value as Model_Detail;

        TextBlock TbInfo = new TextBlock();
        TbInfo.Margin = new Thickness(5, 5, 5, 5);
        TbInfo.TextWrapping = TextWrapping.Wrap;
        TbInfo.Foreground = new SolidColorBrush(Colors.Black);

        Bold TbTitle = new Bold();
        string StrTitle = ObjDetail.QuestionTitle;
        TbTitle.Inlines.Add(StrTitle);

        string StrDetails = " : " + ObjDetail.Detail;

        TbInfo.Inlines.Clear();
        TbInfo.Inlines.Add(TbTitle);
        TbInfo.Inlines.Add(StrDetails);
        return TbInfo;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

At the top of the Page xaml I have declared:

 xmlns:MyConverter="clr-namespace:Magnitude_Gold.MGConverter"

<phone:PhoneApplicationPage.Resources>
        <MyConverter:ListDetailsConverter x:Key="Groupdetails" />
 </phone:PhoneApplicationPage.Resources>

What is wrong with this..?

使用这个,用你的实体或对象替换 Model_Detail

<ContentControl Content="{Binding  Path=Model_Detail Converter={StaticResource Groupdetails}}" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM