简体   繁体   中英

C# windows phone xaml showing invalid xaml error

Hello I am developing a windows phone app and below some code its showing a blue line which reads "invalid xaml" but there's no problem in compilation or run. I am converting image to byte to store it in the isostorage and while binding I'm converting it back. My code is:

<StackPanel Height="auto" Orientation="Horizontal" Margin="0,0,0,0" Grid.RowSpan="2">
        <StackPanel Width="80" Orientation="Horizontal" Height="auto" VerticalAlignment="Top" HorizontalAlignment="Left">
            <Ellipse Margin="0" Height="70" Width="70" HorizontalAlignment="Left" Stroke="{x:Null}">
                <Ellipse.Fill>
                        <ImageBrush Stretch="Fill" ImageSource="{Binding imageBytes, Converter={StaticResource BytesToImageConverter}}"/>
                </Ellipse.Fill>
            </Ellipse>
        </StackPanel>
        <StackPanel Height="auto" Width="380" HorizontalAlignment="Left">
            <TextBlock FontWeight="Bold"  Text="{Binding FirstName}" FontFamily="Segoe WP Semibold" FontSize="30" VerticalAlignment="Top" Margin="5,0,0,0" HorizontalAlignment="Left" />
            <StackPanel>
                    <ListBox SelectionChanged="Contactlist2_SelectionChanged_1" ScrollViewer.VerticalScrollBarVisibility="Disabled" x:Name="Contactlist2" ItemsSource="{Binding PhoneNumbers}" Margin="10,0,0,0">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Height="auto" Margin="5,0,0,0">
                    <TextBlock FontSize="25" Text="{Binding}" FontFamily="Segoe WP"  Margin="10,0,0,0" Width="320" HorizontalAlignment="Left" VerticalAlignment="Top" Height="40" />
                    <TextBlock FontSize="20" Text="mobile" Width="302"/>
                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>

    </ListBox>
        </StackPanel>
    </StackPanel>
    </StackPanel>

If I remove

ImageSource="{Binding imageBytes, Converter={StaticResource BytesToImageConverter}}"

My convertor code is:

 public class BytesToImageConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value != null && value is byte[])
        {
            byte[] bytes = value as byte[];
            MemoryStream stream = new MemoryStream(bytes);
            BitmapImage image = new BitmapImage();
            image.DecodePixelType = DecodePixelType.Logical;
            image.CreateOptions = BitmapCreateOptions.BackgroundCreation;
            image.CreateOptions = BitmapCreateOptions.DelayCreation;
            var bitmapImage = PictureDecoder.DecodeJpeg(stream, 480, 856);
            if (bitmapImage.PixelHeight > bitmapImage.PixelWidth)
            {
                image.DecodePixelWidth = 56;
                image.DecodePixelHeight = 100;
            }
            else
            {
                image.DecodePixelWidth = 100;
                image.DecodePixelHeight = 56;
            }
            image.SetSource(stream);
            return image;
        }

        return null;

    }

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

From imagebrush error goes away. What's wrong? Thank you.

This is due to spaces in the namespace or in the project name. There has always been a problem surrounding this scenario. I thought Microsoft fixed this particular problem :0/

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