Silverlight 4 combobox

G

Gerhard

I have downloaded and installed both VS2010 RC and Silverlight 4 RC. In
testing out functionality, I built a simple RIA Business Application against
the Chinook database. I have a datagrid with the albums, another datagrid
with the tracks that ties to the selected album, and a combobox that ties to
the selected album's artist. When I do my first filter (using the built in
filter text box), all works fine, but if I change the filter, the combobox no
longer stays in sync (the datagrid does though). Can you please help? XAML
is as follows:

<navigation:page
x:Class="Chinook.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Style="{StaticResource PageStyle}"

xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
xmlns:my="clr-namespace:Chinook.Web.Services"
xmlns:my1="clr-namespace:Chinook.Web.Models"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
DataContext="{Binding}">
<sdk:page.Resources>
<CollectionViewSource x:Key="albumTracksViewSource" Source="{Binding
Path=Data.Tracks, ElementName=albumDomainDataSource1}" />
</sdk:page.Resources>
<Grid x:Name="LayoutRoot">
<ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource
PageScrollViewerStyle}" Margin="-58,0,-58,-10">

<StackPanel x:Name="ContentStackPanel" Style="{StaticResource
ContentStackPanelStyle}">

<TextBlock x:Name="HeaderText" Style="{StaticResource
HeaderTextStyle}"
Text="{Binding
Path=ApplicationStrings.HomePageTitle, Source={StaticResource
ResourceWrapper}}"/>
<TextBlock x:Name="ContentText" Style="{StaticResource
ContentTextStyle}"
Text="Home page content"/>
<riaControls:DomainDataSource
AutoLoad="True"
d:DesignData="{d:DesignInstance my1:Artist,
CreateList=true}"
Height="0" LoadedData="artistDomainDataSource_LoadedData"
Name="artistDomainDataSource"
QueryName="GetArtistsQuery"
Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ChinookContext />
</riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
<ComboBox Height="27"
Name="comboBox1"
Width="398"
ItemsSource="{Binding}"
DataContext="{Binding
ElementName=artistDomainDataSource, Path=Data}"
DisplayMemberPath="Name"
SelectedValuePath="ArtistId"
SelectedValue="{Binding ElementName=albumDataGrid,
Path=SelectedItem.ArtistId, Mode=TwoWay}" />
<riaControls:DomainDataSource
AutoLoad="False"
d:DesignData="{d:DesignInstance my1:Album,
CreateList=true}"
Height="0"
LoadedData="albumDomainDataSource_LoadedData"
Name="albumDomainDataSource"
QueryName="GetAlbumsByStartQuery"
Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ChinookContext />
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.QueryParameters>
<riaControls:parameter ParameterName="startString"
Value="{Binding ElementName=startStringTextBox, Path=Text}" />
</riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>
<StackPanel Height="30" Orientation="Horizontal">
<sdk:Label Content="Start String:" Margin="3"
VerticalAlignment="Center" />
<TextBox Name="startStringTextBox" Width="60" />
<Button Command="{Binding Path=LoadCommand,
ElementName=albumDomainDataSource}" Content="Load" Margin="3"
Name="albumDomainDataSourceLoadButton"
Click="albumDomainDataSourceLoadButton_Click" />
</StackPanel>
<sdk:DataGrid AutoGenerateColumns="False" Height="200"
ItemsSource="{Binding ElementName=albumDomainDataSource, Path=Data}"
Name="albumDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected"
Width="400">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn x:Name="albumIdColumn"
Binding="{Binding Path=AlbumId}" Header="Album Id" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="artistIdColumn"
Binding="{Binding Path=ArtistId}" Header="Artist Id" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="titleColumn"
Binding="{Binding Path=Title}" Header="Title" Width="SizeToHeader" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
<riaControls:DomainDataSource
AutoLoad="True"
d:DesignData="{d:DesignInstance my1:Track,
CreateList=true}"
Height="0"
LoadedData="trackDomainDataSource_LoadedData"
Name="trackDomainDataSource"
QueryName="GetTracksQuery"
Width="0">
<riaControls:DomainDataSource.DomainContext>
<my:ChinookContext />
</riaControls:DomainDataSource.DomainContext>
<riaControls:DomainDataSource.FilterDescriptors>
<riaControls:FilterDescriptor
PropertyPath="AlbumId"
Operator="IsEqualTo"
IgnoredValue=""
Value="{Binding ElementName=albumDataGrid,
Path=SelectedItem.AlbumId, Mode=TwoWay}" >
</riaControls:FilterDescriptor>
</riaControls:DomainDataSource.FilterDescriptors>
</riaControls:DomainDataSource>
<sdk:DataGrid AutoGenerateColumns="False" Height="200"
ItemsSource="{Binding ElementName=trackDomainDataSource, Path=Data}"
Name="trackDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected"
Width="400">
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn x:Name="albumIdColumn1"
Binding="{Binding Path=AlbumId}" Header="Album Id" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="bytesColumn"
Binding="{Binding Path=Bytes}" Header="Bytes" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="composerColumn"
Binding="{Binding Path=Composer}" Header="Composer" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="genreIdColumn"
Binding="{Binding Path=GenreId}" Header="Genre Id" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="mediaTypeIdColumn"
Binding="{Binding Path=MediaTypeId}" Header="Media Type Id"
Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="millisecondsColumn"
Binding="{Binding Path=Milliseconds}" Header="Milliseconds"
Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="nameColumn"
Binding="{Binding Path=Name}" Header="Name" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="trackIdColumn"
Binding="{Binding Path=TrackId}" Header="Track Id" Width="SizeToHeader" />
<sdk:DataGridTextColumn x:Name="unitPriceColumn"
Binding="{Binding Path=UnitPrice}" Header="Unit Price" Width="SizeToHeader" />
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</StackPanel>

</ScrollViewer>
</Grid>

</navigation:page>
 
A

Andy O'Neill

Gerhard said:
I have downloaded and installed both VS2010 RC and Silverlight 4 RC. In
testing out functionality, I built a simple RIA Business Application
against
the Chinook database. I have a datagrid with the albums, another datagrid
with the tracks that ties to the selected album, and a combobox that ties
to
the selected album's artist. When I do my first filter (using the built
in
filter text box), all works fine, but if I change the filter, the combobox
no
longer stays in sync (the datagrid does though). Can you please help?
XAML
is as follows:

You want to get into MVVM.
Your viewmodel would then control exactly what goes into the collections
your view binds to.
This sort of problem just goes away.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top