播放地址:20241120-.NET9.0+WPF實戰三類流程化業務邏輯控制-10_嗶哩嗶哩_bilibili
第11-12節 佈局規劃頁面,大概分析接下來的目標
第13節 設計流程圖控制
調整頁面佈局,展示流程圖模組
1 <Window x:Class="WpfApp2.MainView" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 5 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 6 xmlns:local="clr-namespace:WpfApp2" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" 7 mc:Ignorable="d" 8 WindowStartupLocation="CenterScreen" 9 Background="White" 10 Title="MainView" Height="650" Width="1300"> 11 <Grid> 12 <Grid.RowDefinitions> 13 <RowDefinition Height="Auto" /> 14 <RowDefinition /> 15 </Grid.RowDefinitions> 16 <Grid.ColumnDefinitions> 17 <ColumnDefinition Width="200" /> 18 <ColumnDefinition Width="300" /> 19 <ColumnDefinition /> 20 </Grid.ColumnDefinitions> 21 <Button Content="執行" HorizontalAlignment="Stretch" Margin="3" Command="{Binding ExecuteCommand}" /> 22 <TextBlock Text="循序流程" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> 23 <TextBlock Text="流程圖控制" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> 24 <ListView Grid.Row="1" Grid.Column="0"> 25 <ListViewItem Content="AAA" Tag="ProcessA"> 26 <i:Interaction.Triggers> 27 <i:EventTrigger EventName="PreviewMouseLeftButtonDown"> 28 <i:CallMethodAction MethodName="ListViewItem_MouseLeftButtonDown" TargetObject="{Binding}" /> 29 </i:EventTrigger> 30 </i:Interaction.Triggers> 31 </ListViewItem> 32 <ListViewItem Content="BBB" Tag="ProcessB"> 33 <i:Interaction.Triggers> 34 <i:EventTrigger EventName="PreviewMouseLeftButtonDown"> 35 <i:CallMethodAction MethodName="ListViewItem_MouseLeftButtonDown" TargetObject="{Binding}" /> 36 </i:EventTrigger> 37 </i:Interaction.Triggers></ListViewItem> 38 <ListViewItem Content="CCC" Tag="ProcessC"> 39 <i:Interaction.Triggers> 40 <i:EventTrigger EventName="PreviewMouseLeftButtonDown"> 41 <i:CallMethodAction MethodName="ListViewItem_MouseLeftButtonDown" TargetObject="{Binding}" /> 42 </i:EventTrigger> 43 </i:Interaction.Triggers></ListViewItem> 44 <ListViewItem Content="DDD" Tag="ProcessD"> 45 <i:Interaction.Triggers> 46 <i:EventTrigger EventName="PreviewMouseLeftButtonDown"> 47 <i:CallMethodAction MethodName="ListViewItem_MouseLeftButtonDown" TargetObject="{Binding}" /> 48 </i:EventTrigger> 49 </i:Interaction.Triggers></ListViewItem> 50 </ListView> 51 <ListBox Grid.Row="1" Grid.Column="1" AllowDrop="True" ItemsSource="{Binding ProcessList}"> 52 <i:Interaction.Triggers> 53 <i:EventTrigger EventName="Drop"> 54 <i:CallMethodAction MethodName="ListBox_Drop" TargetObject="{Binding}" /> 55 </i:EventTrigger> 56 </i:Interaction.Triggers> 57 <ListBox.ItemTemplate> 58 <DataTemplate> 59 <TextBlock Text="{Binding Name}"> 60 </TextBlock> 61 </DataTemplate> 62 </ListBox.ItemTemplate> 63 </ListBox> 64 <ItemsControl Grid.Row="1" Grid.Column="2" Background="Transparent" AllowDrop="true" ItemsSource="{Binding ProcessList}"> 65 <ItemsControl.ItemsPanel> 66 <ItemsPanelTemplate> 67 <Canvas /> 68 </ItemsPanelTemplate> 69 </ItemsControl.ItemsPanel> 70 71 </ItemsControl> 72 </Grid> 73 </Window>
調整程式碼後,拖拽內容到順序流程會看到流程圖控制裡會有內容顯示