wpf游戏引擎主界面实现3

发布于:2025-06-20 ⋅ 阅读:(17) ⋅ 点赞:(0)

1.ProjectLayout.xaml

<UserControl x:Class="PrimalEditor.Editors.ProjectLayoutView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:PrimalEditor.Editors"
             xmlns:proj="clr-namespace:PrimalEditor.GameProject"
             mc:Ignorable="d" 
             
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>


        <Grid.RowDefinitions>
            <RowDefinition Height="32"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button Content="Add Scene" Width="96" VerticalAlignment="Center" Focusable="False" Grid.Row="0" HorizontalAlignment="Left" Margin="20,0,0,0"
            Command="{Binding AddSceneCommand}" />
        <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <ItemsControl ItemsSource="{Binding Scenes}">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel/>

                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>

                        <Expander IsExpanded="{Binding IsActive,Mode=OneWay}">
                            <Expander.Header>
                                <Grid>

                                    <StackPanel Orientation="Horizontal">


                                        <TextBlock Text="{Binding Name}"/>
                                        <Button Content="Remove"
                                            Command="{Binding DataContext.RemoveSceneCommand,RelativeSource={RelativeSource AncestorType=UserControl}}"
                                            CommandParameter="{Binding}" Margin="20,0" Focusable="False"
                                            />

                                        <Button Content="+" IsEnabled="True"
                                                Click="OnAddGameEntity_Button_Click"
                                                />


                                    </StackPanel>


                                </Grid>
                            </Expander.Header>
                            <ListBox ItemsSource="{Binding GameEntities}" IsEnabled="True" SelectionMode="Extended" 
                                     SelectionChanged="OnGameEntities_ListBox_SelectionChanged">

                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Name}"/>
                                            <Button Content="Remove" 
                                                    Command="{Binding ParentScene.RemoveGameEntityCommand}" 
                                                    CommandParameter="{Binding}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Expander>

                    </DataTemplate>

                </ItemsControl.ItemTemplate>
            </ItemsControl>

        </ScrollViewer>


    </Grid>
</UserControl>
 


网站公告

今日签到

点亮在社区的每一天
去签到