Resolved How can I turn on both vertical and horizontal borders for the itemTemplate Control?

destro

Well-known member
Joined
Mar 28, 2020
Messages
46
Programming Experience
1-3
I created the item template control and set its border thickness and color in Data Template. This is my ItemTemplate code:

ItemTemplateControl:
<ItemsControl  x:Name="VimshottariDasha" Margin="-10,83,-124,-267" FontSize="16" Grid.ColumnSpan="3" BorderThickness="0">
                            <ItemsControl.ItemTemplate>

                                <DataTemplate>
                                    <Border BorderThickness="1" BorderBrush="DimGray">

                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition SharedSizeGroup="Col1" />
                                                <ColumnDefinition SharedSizeGroup="Col2" />
                                                <ColumnDefinition SharedSizeGroup="Col3" />
                                            </Grid.ColumnDefinitions>

                                            <Button Background="Transparent" BorderThickness="0" x:Name="DashaButton" Grid.Column="0" Content="{Binding rulerName}" Command="{Binding SelectedDasha}" CommandParameter="{Binding Content, RelativeSource={RelativeSource Self}}"/>
                                            <TextBlock Grid.Column="1" Text="{Binding rulerStartDate, StringFormat=dd-MMM-yyyy HH:mm:ss}"  />
                                            <TextBlock Grid.Column="2" Text="{Binding rulerEndDate, StringFormat=dd-MMM-yyyy HH:mm:ss}"/>
                                        </Grid>
                                    </Border>
                                </DataTemplate>

                            </ItemsControl.ItemTemplate>

How do I show both vertical and horizontal borders regardless of stack orientation?

The same thing happens in another itemTemplate but in reverse, whose stack orientation is set to Horizontal. I can see vertical borders in the second item Control but no Horizontal borders.

This is the current Output, it has horizontal Borders inside but no vertical ones(Stack orientation is vertical by default)
mci2dsgTAq.png


This is second ItemControl with horizontal stack orientation it is missing horizontal borders.


fQC0BByrbK.png
 
If you want a border around every grid element, then declare a border around each grid element. Currently you are only declaring a border around the grid. (Line 5,18)
 
If you want a border around every grid element, then declare a border around each grid element. Currently you are only declaring a border around the grid. (Line 5,18)
Thanks a lot.. i Did exactly that. Settings borders around labels and button in the template. Works now. Thanks
 

Latest posts

Back
Top Bottom