Hi
I am trying to bind my control to two collections (bind the header of a groupbox to a collection and the content to another associated collection).
here is the situation in detail:
I have two tables:
Employees(empID, EmpName, empDepartmentId)
and
Departments(depID, depName)
I want to bind these to a flow layout control (
devexpress) so that the control's groupboxes headers show the department Name and the content shows employees in the department
The code below works fine for the header but I can't figure out how to add the employee names.
I put ??? where I should bind to the Employees.
I think I have to bind to a collection that is filtered with the Id of the current Item's depID property but I don't know how, something like this:
XPCollection<employee> DepEmployees = new XPCollection<employee>(new BinaryOperator("empDepartmentId", currentgroupbox.depID????? , BinaryOperatorType.Equal));
and then in Xaml:
<TextBlock Text="{Binding DepEmployees , RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}}"/>
What I have tried:
Xaml:
<dxlc:FlowLayoutControl
x:Name="Departments"
Background="Transparent"
ItemSpace="12"
LayerSpace="12"
Orientation="Horizontal">
<dxlc:FlowLayoutControl.ItemTemplate>
<DataTemplate>
<dxlc:GroupBox
Width="200"
Height="250"
Content="{Binding}"
Cursor="Hand"
FontFamily="Segoe UI Light"
FontSize="14"
Header="{Binding}"
MaximizeElementVisibility="Visible"
Padding="0">
<dxlc:GroupBox.HeaderTemplate>
<DataTemplate>
<TextBlock Margin="1">
<Run FontFamily="Segoe UI" Text="{Binding depName}" />
<Run Text=" , " />
<Run Text="{Binding depID}" />
</TextBlock>
</DataTemplate>
</dxlc:GroupBox.HeaderTemplate>
<dxlc:GroupBox.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding empName ???????}" />
</DataTemplate>
</dxlc:GroupBox.ContentTemplate>
</dxlc:GroupBox>
</DataTemplate>
</dxlc:FlowLayoutControl.ItemTemplate>
</dxlc:FlowLayoutControl>
CSharp
Departments.ItemsSourcenew = XPCollection(typeof(Departments));