This question is locked. New answers and comments are not allowed.
Hi,
I am working on this scenario where the drop down list boxes are in each row of a Telerik Grid.
At runtime I want to bind the drop down list box to the database and the mechanism is similar to this (http://social.msdn.microsoft.com/Forums/vstudio/en-US/64f36ca4-bde9-4f32-8260-2b84e53bd8ca/wpf-datagridcomboboxcolumn-problem?forum=wpf)
But I found that it is applicable for WPF in Windows Forms and the syntax
<ComboBox ItemsSource="{Binding Persons, RelativeSource={RelativeSource AncestorType=Window}}" DisplayMemberPath="NAME" SelectedValuePath="NAMEID" SelectedValue="{Binding NAMEID}" />
and DataContext = this; (code behind)
does not apply for Windows 8.1
The way I am doing this
and in code behind
If my technique of populating the combo boxes is wrong, I kindly request you to let me know how to do it correctly.
Thanks,
Rajesh.
I am working on this scenario where the drop down list boxes are in each row of a Telerik Grid.
At runtime I want to bind the drop down list box to the database and the mechanism is similar to this (http://social.msdn.microsoft.com/Forums/vstudio/en-US/64f36ca4-bde9-4f32-8260-2b84e53bd8ca/wpf-datagridcomboboxcolumn-problem?forum=wpf)
But I found that it is applicable for WPF in Windows Forms and the syntax
<ComboBox ItemsSource="{Binding Persons, RelativeSource={RelativeSource AncestorType=Window}}" DisplayMemberPath="NAME" SelectedValuePath="NAMEID" SelectedValue="{Binding NAMEID}" />
and DataContext = this; (code behind)
does not apply for Windows 8.1
The way I am doing this
<telerikGrid:RadDataGrid x:Name="QuestionAnswersGrid" AutoGenerateColumns="False" AlternateRowBackground="Lavender" ScrollViewer.HorizontalScrollMode="Auto" ScrollViewer.VerticalScrollMode="Auto" GroupHeaderDisplayMode="Frozen" Margin="51,44,45,36" Grid.Row="1" Width="1200" UserGroupMode="Disabled"> <telerikGrid:RadDataGrid.GroupDescriptors> <telerikGrid:PropertyGroupDescriptor PropertyName="Room" /> </telerikGrid:RadDataGrid.GroupDescriptors> <telerikGrid:RadDataGrid.Columns> <!--<telerikGrid:DataGridTextColumn PropertyName="Question" Header="Question" SizeMode="Fixed" Width="800"/>--> <telerikGrid:DataGridTemplateColumn Header="Question" SizeMode="Fixed" Width="700"> <telerikGrid:DataGridTemplateColumn.CellContentTemplate> <DataTemplate> <StackPanel> <TextBlock Name="{Binding QID}" Text="{Binding Question}" TextWrapping="Wrap" /> </StackPanel> </DataTemplate> </telerikGrid:DataGridTemplateColumn.CellContentTemplate> </telerikGrid:DataGridTemplateColumn> <telerikGrid:DataGridTemplateColumn Header="Answer" SizeMode="Fixed" Width="200"> <telerikGrid:DataGridTemplateColumn.CellContentTemplate > <DataTemplate> <StackPanel> <!--<ComboBox Name="{Binding QID}" Height="40">--> <ComboBox ItemsSource="{Binding dropdownList, RelativeSource={RelativeSource Mode=TemplatedParent}}" DisplayMemberPath="{Binding AD_Ans}" SelectedValuePath="{Binding AD_Ans, Mode=TwoWay}" SelectedValue="{Binding AD_Ans}" Height ="40" /> <!--<ComboBoxItem Content="Fail" Name="Fail" /> <ComboBoxItem Content="Pass" Name="Pass" /> <ComboBoxItem Content="Inconclusive" Name="Inconclusive" /> <ComboBoxItem Content="Pass W/Comments" Name="Pass W/Comments" />--> <!--</ComboBox>--> </StackPanel> </DataTemplate> </telerikGrid:DataGridTemplateColumn.CellContentTemplate> </telerikGrid:DataGridTemplateColumn> <telerikGrid:DataGridTemplateColumn Header="Notes" SizeMode="Fixed" Width="150"> <telerikGrid:DataGridTemplateColumn.CellContentTemplate > <DataTemplate> <StackPanel> <Image x:Name="IMG" Source="Assets/Mail.png" Stretch="Uniform" Width="40" Height="40" /> </StackPanel> </DataTemplate> </telerikGrid:DataGridTemplateColumn.CellContentTemplate> </telerikGrid:DataGridTemplateColumn> <telerikGrid:DataGridTemplateColumn Header="Photo" SizeMode="Fixed" Width="150"> <telerikGrid:DataGridTemplateColumn.CellContentTemplate > <DataTemplate> <StackPanel> <Image x:Name="IMG" Source="Assets/Camera-01.png" Stretch="Uniform" Width="40" Height="40" /> </StackPanel> </DataTemplate> </telerikGrid:DataGridTemplateColumn.CellContentTemplate> </telerikGrid:DataGridTemplateColumn> </telerikGrid:RadDataGrid.Columns> </telerikGrid:RadDataGrid>and in code behind
List<QuestionDetails> questionList;List<DropDownDetails> dropdownList;public Questions() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.navigationHelper.LoadState += navigationHelper_LoadState; this.navigationHelper.SaveState += navigationHelper_SaveState; DataContext = this; }protected async override void OnNavigatedTo(NavigationEventArgs e) { navigationHelper.OnNavigatedTo(e); try { await PopulateQuestions(); this.QuestionAnswersGrid.ItemsSource = questionList; await PopulateDropDown(); } catch(Exception ex) { Debug.WriteLine(ex.Message.ToString()); } finally { } }private async Task PopulateQuestions() { var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "demo.db"); SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbpath); var stringSQL = string.Format(@"sqlstatement"); questionList = await conn.QueryAsync<QuestionDetails>(stringSQL); } private async Task PopulateDropDown() { try { var dbpath1 = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "demo.db"); SQLiteAsyncConnection conn = new SQLiteAsyncConnection(dbpath1); var stringSQL1 = string.Format(@"sqlstatement"); dropdownList = await conn.QueryAsync<DropDownDetails>(stringSQL1); //DataContext = this; } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } }If my technique of populating the combo boxes is wrong, I kindly request you to let me know how to do it correctly.
Thanks,
Rajesh.