通用工业视觉软件设计之项目栏-添加新项目流程-1

一 UI

<Grid Background="Black">
    <Grid.RowDefinitions>
        <RowDefinition Height="36"></RowDefinition>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0" Orientation="Horizontal">
        <Button
            Height="36"
            FontSize="26"
            Style="{StaticResource ProjectBar_Btn_Style}"
            Content="&#xe609;"
            Command="{Binding Addproject}"
            IsEnabled="{Binding AddControlIsEnabled}"
            ></Button>
        <Button
           Height="36"
           FontSize="26"
           Style="{StaticResource ProjectBar_Btn_Style}"
           Content="&#xe8c1;"
            Command="{Binding Deteproject}"
            CommandParameter="{Binding ElementName=ProListBox}"
             IsEnabled="{Binding AddControlIsEnabled}"
           ></Button>
        <Label VerticalContentAlignment="Center" HorizontalAlignment="Center" Content="[" Foreground="White" FontSize="18"/>
        <Label VerticalContentAlignment="Center" HorizontalAlignment="Center" Content="{Binding SelectProName}" Foreground="White" FontSize="15"/>
        <Label VerticalContentAlignment="Center" HorizontalAlignment="Center" Content="]" Foreground="White" FontSize="18"/>
    </StackPanel>

二 后端

        /// <summary>
        /// 构造器
        /// </summary>
        public ProjectbarViewModel()
        {
            this.Addproject = new RelayCommand();
            this.Addproject.DoExecute = new Action<object>(AddNewProject);
            this.Addproject.DoCanExecute = new Func<object, bool>((o) =>
            {
                return true;
            });

        }

        /// <summary>
        /// 创新新项目流程
        /// </summary>
        /// <param name="obj"></param>
        public void AddNewProject(object obj)
        {
            // 1.判断有没有创建解决方案
            if(SysProcessSln.SolutionName == string.Empty || SysProcessSln.SolutionPath ==string.Empty)
            {
                MessageBox.Show("未创建解决方案!");
                return;
            }
            // 2.弹出创建解决方案的框,输入项目名称


            // 3.更新ListBox的框



        }

三 绑定

   public partial class Projectbar : UserControl
   {
       public Projectbar()
       {
           InitializeComponent();

           this.DataContext = new ProjectbarViewModel();
       }
   }
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐