I'm using WPF and trying to show a datagrid with a combobox for one of the columns where both the grid and the combobox are populated by datasets.
I'm running into 'Resource can not be found' errors in the XAML.
It's the first time I'm trying to do this and I may need more pointers to make it work once this hurdle is overcome.
My architecture is a bit unique and may be contributing to the difficulty.
I have an overarching Namespace (MyNameSpace) with applications et all under it, as follows
Architecture:
MyNameSpace
--MyNameSpaceSharableMembersForWPF (Application)
----Class1
----Class2
----OtherClasses
----Modules
--MyApplication (Application)
----MyMainScreen
----OtherScreens
--AnotherApplication
I'm currently working in MyMainScreen of MyApplication.
Here's a XAML snippet. Perhaps I'm not properly declaring xmlns:local. I'm new at this.
MyMainScreen.xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit"
x:Class="MyMainScreen"
xmlns:local="clr-namespace:MyNameSpace.My"
Title="" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<DataGrid Name="M_Records" HorizontalAlignment="Center" >
<DataGrid.Columns>
<DataGridTextColumn Width="auto" Header="Name" Binding="{Binding D_Name}" />
<DataGridTextColumn Width="auto" Header="Reoccur" Binding="{Binding D_Reoccurrence}" />
<DataGridComboBoxColumn Width="auto" Header="Done By" ItemsSource="{Binding Source={StaticResource local:ds_SRecords}}" />
<!-- ERROR: RESOURCE local:ds_SRecords COULD NOT BE RESOLVED -->
<DataGridTextColumn Width="auto" Header="Instructions" Binding="{Binding D_Instructions}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
Here's an over-simplified snippet for the code-behind. Maybe I need more stuff to get it all to work. Appreciate some help.
MyMainScreen.xaml.vb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports MyNameSpaceSharableMembersForWPF
Imports MyNameSpace
Public Class MyMainScreen
Private ds_GridDataSet As New DataSet
Private ds_SRecords As New DataSet
Public Sub New()
' This call is required by the designer.
InitializeComponent()
'Some code to fill ds_SRecords - not included
'Some code to fill ds_GridDataSet - not included
M_Records.DataContext = ds_GridDataSet.Tables(0).DefaultView
End Sub
End Class
Thanks
Harlan Black