0

This is simple by XAML but how to do this same by C#? Need to change Orientation between Horizontal and Vertical.

<ListView x:Name="MyListView">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsStackPanel Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
</ListView>

1 Answer 1

1

Ok. Problem solved. The next code works well.

        if(MyListView != null)
        {
            ListView ListViewInfo = MyListView;
            ItemsStackPanel ItemsStackPanelInfo = ListViewInfo.ItemsPanelRoot as ItemsStackPanel;
            if ("something is true or false") ItemsStackPanelInfo.Orientation = Orientation.Horizontal;
            else ItemsStackPanelInfo.Orientation = Orientation.Vertical;
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.