Hi,
I tried to bind data to a combo box located in a child column layout. At first, the grdStart will be displayed to the users. When the user clicks on one of the row, GridOrd will show some records. I'm using XamWebView also. Here is the code behind:
. . .
InitializeComponent(); //Get data from WFC prxy.StartListCompleted += new EventHandler<StartListCompletedEventArgs>(prxy_StartListCompleted); prxy.StartListAsync();
void prxy_StartListCompleted(object sender, StartListCompletedEventArgs e) { (this.FindName("grdStart") as XamWebGrid).ItemsSource = e.Result; (this.FindName("grdStart") as XamWebGrid).Visibility = Visibility.Visible; }
private void grdStart_CellClicked(object sender, CellClickedEventArgs e) {
prxy.GetHeaderCompleted += new EventHandler<GetHeaderCompletedEventArgs> (prxy_GetHeaderCompleted); prxy.GetHeaderAsync();
}
void prxy_GetHeaderCompleted(object sender, GetHeaderCompletedEventArgs e) { (this.FindName("grdOrd") as XamWebGrid).ItemsSource = e.Result; (this.FindName("grdOrd") as XamWebGrid).Visibility = Visibility.Visible;
//Combo Box data prxy.GetCagegoryCompleted += new EventHandler<GetCagegoryCompletedEventArgs>(prxy_GetCagegoryCompleted); prxy.GetCagegoryAsync(); }
void prxy_GetCagegoryCompleted(object sender, GetCagegoryCompletedEventArgs e) {
public class Category : EntityBase { public string Id { get; set; } public string Desc { get; set; } }
Here is Xaml code
<Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition Height="*"></RowDefinition> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"></ColumnDefinition> </Grid.ColumnDefinitions>
<igTileView:XamWebTileView Name="TestView" Width="auto" Height="auto" Grid.Column="0" Grid.Row="0">
<igTileView:XamWebTileView.TilePanelSettings> <igTileView:TilePanelSettings MinimizedStripWidth="30" MinimizedStripLocation="Bottom">
</igTileView:TilePanelSettings>
</igTileView:XamWebTileView.TilePanelSettings> <igTileView:TilePane Name="Test1" Key="Test1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <igTileView:TilePane.Header> <TextBlock Text="Start" FontSize="14" FontWeight="Bold" /> </igTileView:TilePane.Header>
<Grid ShowGridLines="False" Height="auto" Width="auto">
<Grid.RowDefinitions> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions>
<igGrid:XamWebGrid Name="grdStart" ColumnLayoutAssigned="grdStart_ColumnLayoutAssigned" CellClicked="grdStart_CellClicked" Grid.Column="0" Grid.Row="0" BorderThickness="1" Background="LightGray"></igGrid:XamWebGrid>
</Grid> </igTileView:TilePane>
<igTileView:TilePane Name="Test2" IsEnabled="False" Height="auto" >
<igTileView:TilePane.Header> <TextBlock Text="Hello1" FontSize="14" FontWeight="Bold" /> </igTileView:TilePane.Header>
<Grid ShowGridLines="False" Height="auto" Width="auto"> <Grid.RowDefinitions> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <igGrid:XamWebGrid Name="grdOrd" Grid.Column="0" Grid.Row="0" BorderThickness="1" Background="LightGray">
<igGrid:XamWebGrid.Columns> <igGrid:ColumnLayout Key="OrdDet" HeaderVisibility="false" > <igGrid:ColumnLayout.Columns>
<igGrid:TemplateColumn Key="CatName" Width="120" HeaderText="Category" HorizontalContentAlignment="Stretch"> <igGrid:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock x:Name="CatDisplay" Text="{Binding Desc}" /> </DataTemplate> </igGrid:TemplateColumn.ItemTemplate>
<igGrid:TemplateColumn.EditorTemplate> <DataTemplate> <ComboBox x:Name="cmboCat" ItemsSource="{Binding}" Loaded="cmboCat_Loaded" /> </DataTemplate> </igGrid:TemplateColumn.EditorTemplate> </igGrid:TemplateColumn> </igGrid:ColumnLayout.Columns> </igGrid:ColumnLayout> </igGrid:XamWebGrid.Columns> <igGrid:XamWebGrid.EditingSettings> <igGrid:EditingSettings AllowEditing="Row" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True" /> </igGrid:XamWebGrid.EditingSettings> </igGrid:XamWebGrid>
</igTileView:XamWebTileView>
</Grid>
Please help! Thanks!
So, after looking at your sample, probably the best way to do this, is to populate in the combobox in the cell entering edit mode event. As the combo won't exist until you enter edit mode.
You'll be able to get the combobox in the event args of that event.
-SteveZ
Sorry, i told you the wrong event, the event you want to listen to is CellEnteredEditMode:
private void xamGrid_CellEnteredEditMode(object sender, EditingCellEventArgs e)
{
if(e.Cell.Column.Key == "YourTemplateColumn")
ComboBox editor = (ComboBox)e.Editor;
editor.ItemsSource = // Your ItemSource