WPF: aligning my list of swap items ....;)?

for reasons based on preservation. I have the following objects in XAML graphics:

  • A WorkArea,
  • Contains worksheets,
  • Containing work items

WorkArea, workSheets are instances of ItemsControl.

To get started: the reason I don't use the standard elements is because my files will be loaded / saved - they represent a business conflict (actually the trading application's area of ​​operation) and I want few to have them. " redundant "items as I can. I especially don't want to bind to user level controls that are third party and change DLL names on a regular basis (during updates - the major version is coded there), and I'm not sure if I won't replace them at all, so I'd rather go with my own own "slender" objects.

The WorkArea corresponds to the window (there is actually a WorkAreaWindow that will accept the WorkArea as ContentItem.

The worksheets should act like a TabControl - you can switch between them.

How can I do it?;)

I get the impression that with templating mechanisms I could "render" the worksheets as pages in a TabControl, but I pretty much lost them entirely. Can anyone enlighten me?

This is how far I got:

My Herarchy WorkArea -> WorkSheet (s) -> WorkItem (s)

The WorkArea should be presented as a TabControl with one tab in the WorkSheet.

WorkArea:

        <local:WorkArea x:Name="WorkArea">
            <local:WorkArea.Template>
                <ControlTemplate>
                    <TabControl>
                        <ItemsPresenter />
                    </TabControl>
                </ControlTemplate>
            </local:WorkArea.Template>

            <local:WorkArea.ItemTemplate>
                <DataTemplate>
                    <TabItem Header="{Binding Path=Title}">
                        <ContentPresenter />
                    </TabItem>
                </DataTemplate>
            </local:WorkArea.ItemTemplate>
            <local:WorkSheet Title="Markets">
                <local:WorkTile local:WorkSheet.Row="2" local:WorkSheet.Column="3">
                    test-11

      

Now I see a TabControl with one tab. No text, all content in one tab. Does anyone know how to split this further?

+2


a source to share


1 answer


You should carefully read Josh Smith's introduction to MVVM here and see the source code for the demo application. The demo app is almost what you are asking for. It dynamically creates a tabbed interface based on custom classes for "contacts" data using data templates, observable collection binding, and tabcontrol / tabitem. Some of the MVVM and team stuff might not be your thing, but some of the code does what you're looking for. XAML has no code at all. You would simply set this data context of your window to an instance of the workspace class which would have an observable collection of worksheets, which in turn would have an observable collection of workItems and item / data templates would do everything.



+3


a source







All Articles