Bip
Bip

Reputation: 913

WPF control develop idea

OK, I want to create a control that is like a Stackpanel with TextBlock on the left, something like:

Picture

The TextBlock need to be editable. So, the question is from whom I need to inherit to make that since cannot from Stackpanel?

Upvotes: 1

Views: 123

Answers (1)

brunnerh
brunnerh

Reputation: 184296

That is basically a HeaderedItemsControl with a custom Template.

The template could be a Grid with two columns, one containing a rotated ContentPresenter which is bound to the header properties, on the right you would have an ItemsPresenter for the items.

e.g.

<Style TargetType="HeaderedItemsControl"> <!-- Implicitly applied -->
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="HeaderedItemsControl">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <ContentPresenter ContentSource="Header">
                        <ContentPresenter.LayoutTransform>
                            <RotateTransform Angle="-90"/>
                        </ContentPresenter.LayoutTransform>
                    </ContentPresenter>
                    <ItemsPresenter Grid.Column="1"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
<HeaderedItemsControl Header="Lorem Ipsum" ItemsSource="ABCDEF"/>

Upvotes: 5

Related Questions