C********r 发帖数: 145 | 1 Sorry, I have no Chinese software on this machine...
I am new to WPF and Infragistics Controls. I am trying to accomplish a
seemly simple task. use Xamdatagrid to display a collection of data records
retrieved from database.Besides the columns from the data records, I want an
additional unbounded column to contain a checkbox. I am having a really
hard time to get the databinding to work. I have spend 2 days to look up
examples and tutorials but none are complete or easy to understand(for me at
least). If I just set the datasource in the code behind and set
autogeneratecolumn to true, it works ok. But that's not what I need, I need
to control which field is visible in the grid and also add the checkbox
column. When I run the code below, I can see data is available but the
datagrid is blank. I think it's because I didn't specify binding of the
columns between the grid and datasource. But what's the syntax to do this
explicitly for XAMDatagrid? Please help me to see what I have done wrong in
code below and what I haven't done to get the desired behavior. I have no
BAOZI but sincere appreciation...
Omitted some style definition in the markup below:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:c="clr-namespace:POAPopup"
xmlns:igDP="http://infragistics.com/DataPresenter"
mc:Ignorable="d"
d:DesignHeight="326" d:DesignWidth="410" SizeToContent="
WidthAndHeight" Loaded="Window_Loaded" >
AllowDelete="False" AllowAddNew="False" HighlightAlternateRecords="True" />
="60" >
"{StaticResource CheckBoxInCellStyle}" />
Visibility="Collapsed" " />
Tag="{Binding Path=Code}" />
Width="280" />
Code behind for the dataprovider
public class POADataProvider
{
ObservableCollection _HICollection = new
ObservableCollection();
public ObservableCollection HICollection
{
get { return _HICollection; }
set { _HICollection = value; }
}
public ObservableCollection GetHICollection()
{
//omitted code to connect to DB and query data and add to _
HICollection
return _HICollection;
}
}
| L******e 发帖数: 136 | 2 is your binding source an observable collection? it has to be obserbable
collection for infragistics xamdatagrid
for syntax google "infragistics binding object/s" | d***m 发帖数: 11 | 3 Haven't use Xamdatagrid but normally you binding the data source(a
collection) to DataSource not DataContext.
DataContext="{Binding Source={StaticResource POAObjs}}"
records
an
at
need
【在 C********r 的大作中提到】 : Sorry, I have no Chinese software on this machine... : I am new to WPF and Infragistics Controls. I am trying to accomplish a : seemly simple task. use Xamdatagrid to display a collection of data records : retrieved from database.Besides the columns from the data records, I want an : additional unbounded column to contain a checkbox. I am having a really : hard time to get the databinding to work. I have spend 2 days to look up : examples and tutorials but none are complete or easy to understand(for me at : least). If I just set the datasource in the code behind and set : autogeneratecolumn to true, it works ok. But that's not what I need, I need : to control which field is visible in the grid and also add the checkbox
|
|