silverlight master-detail with two listboxes in pure xaml with ria services throwing exception

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-05-28T14:45:12Z Indexed on 2010/05/29 15:22 UTC
Read the original article Hit count: 695

Hi, I was trying to achieve master-detail with 2 ListBox, 2 DomainDataSource and a IValueConverter, when entering the page it throws the random error it does when your xaml is invalid: "AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 24 Position: 61]"

Which is in fact the start position of where I am binding the listbox selected item with converter to the parameter's value of my DomainDataSource. I would love to achieve this by pure xaml, I did it by code behind and that works but I don't like it :p

When the parameter is a hard-coded integer 1, it works, so I assume it's the value binding

My code is below here, thanks in advance for at least looking :) (taken into accound all the xmlns's & usings are correct)

Xaml:

<Grid x:Name="LayoutRoot">
    <Grid.Resources>
        <helpers:ListItemtoIdListValueConverter x:Key="mListConverter" />
    </Grid.Resources>
    <riacontrols:DomainDataSource x:Name="GetLists" DomainContext="{StaticResource DbContext}" LoadSize="20" QueryName="GetLists" AutoLoad="True" />
    <riacontrols:DomainDataSource x:Name="GetListItems" DomainContext="{StaticResource DbContext}" LoadSize="20" QueryName="GetListItemsById" AutoLoad="True">
        <riacontrols:DomainDataSource.QueryParameters>
            <riadata:Parameter ParameterName="id" Value="{Binding ElementName=ListBoxLists, Path=SelectedItem, Converter={StaticResource mListConverter}}" />
        </riacontrols:DomainDataSource.QueryParameters>
    </riacontrols:DomainDataSource>
    <activity:Activity IsActive="{Binding IsBusy, ElementName=ListBoxListItems}">
        <StackPanel Orientation="Horizontal">
            <ListBox x:Name="ListBoxLists" ItemsSource="{Binding Data, ElementName=GetLists, Mode=OneWay}" Width="150" Margin="0,0,10,10" />
            <ListBox x:Name="ListBoxListItems" ItemsSource="{Binding Data, ElementName=GetListItems, Mode=OneWay}" Width="150" Margin="0,0,10,10" />
        </StackPanel>
    </activity:Activity>
</Grid>

IValueConverter:

public class ListItemtoIdListValueConverter: IValueConverter
{
    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        list mList = (list)value;
        if (mList != null)
            return mList.id;
        else
            return null;
    }

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

    #endregion
}

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about xaml