diff --git a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs index 19706ae..65ff3b6 100644 --- a/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs +++ b/DM_Weight/ViewModels/AddToJiaoJieWindowViewModel.cs @@ -13,10 +13,12 @@ using Prism.Services.Dialogs; using SqlSugar; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Data; namespace DM_Weight.ViewModels { @@ -39,6 +41,8 @@ namespace DM_Weight.ViewModels { // 取消消息订阅 _eventAggregator.GetEvent().Unsubscribe(DoMyPrismEvent); + + _eventAggregator.GetEvent().Unsubscribe(SetIsSelected); } @@ -54,6 +58,8 @@ namespace DM_Weight.ViewModels public void OnNavigatedTo(NavigationContext navigationContext) { _eventAggregator.GetEvent().Subscribe(DoMyPrismEvent); + + _eventAggregator.GetEvent().Subscribe(SetIsSelected); RequestData(); } private PortUtil _portUtil; @@ -453,6 +459,30 @@ namespace DM_Weight.ViewModels //} //MessageBox.Show("返回值:" + dialogResult.Result.ToString()); } + //设置选中药箱的复选框状态 + private void SetIsSelected(ChannelStock channelStock) + { + if (channelStock != null) + { + channelStock.ChannelLst.IsSelected = !channelStock.ChannelLst.IsSelected; + if (channelStock != null && ChannelStocks != null) + { + ChannelStocks = ChannelStocks.Select(x => + { + for (int i = 0; i < ChannelStocks.Count; i++) + { + if (ChannelStocks[i].DrawerNo == channelStock.DrawerNo) + { + ChannelStocks[i].ChannelLst = channelStock.ChannelLst; + } + } + return x; + }).ToList(); + } + ICollectionView vw = CollectionViewSource.GetDefaultView(ChannelStocks); + vw.GroupDescriptions.Add(new PropertyGroupDescription("ChannelLst")); + } + } } } \ No newline at end of file diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml b/DM_Weight/Views/AddToJiaoJieWindow.xaml index fa85c17..6db9915 100644 --- a/DM_Weight/Views/AddToJiaoJieWindow.xaml +++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml @@ -143,7 +143,7 @@ + materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed"> diff --git a/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs b/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs index 8f1b46f..e90d01e 100644 --- a/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs +++ b/DM_Weight/Views/AddToJiaoJieWindow.xaml.cs @@ -1,4 +1,7 @@ -using System; +using DM_Weight.Models; +using DM_Weight.msg; +using Prism.Events; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -20,9 +23,42 @@ namespace DM_Weight.Views /// public partial class AddToJiaoJieWindow : UserControl { - public AddToJiaoJieWindow() + IEventAggregator _eventAggregator; + public AddToJiaoJieWindow(IEventAggregator eventAggregator) { InitializeComponent(); + _eventAggregator = eventAggregator; + } + + //展开 + private void Expander_Expanded(object sender, RoutedEventArgs e) + { + //Expander expander = sender as Expander; + //if (expander != null) + //{ + // // 假设你的数据在DataContext中 + // List data = expander.DataContext as List; + // if (data != null&&data.Count>0) + // { + // // 使用data做你需要的操作 + // } + //} + } + //收起 + private void Expander_Collapsed(object sender, RoutedEventArgs e) + { + Expander expander = sender as Expander; + if (expander != null) + { + // 假设你的数据在DataContext中 + CollectionViewGroup group = expander.DataContext as CollectionViewGroup; + if (group != null) + { + ChannelStock internalGroup = group.Items[0] as ChannelStock; + + _eventAggregator.GetEvent().Publish(internalGroup); + } + } } } } diff --git a/DM_Weight/msg/IsSelectedEvent.cs b/DM_Weight/msg/IsSelectedEvent.cs new file mode 100644 index 0000000..1c159d8 --- /dev/null +++ b/DM_Weight/msg/IsSelectedEvent.cs @@ -0,0 +1,14 @@ +using DM_Weight.Models; +using Prism.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DM_Weight.msg +{ + internal class IsSelectedEvent:PubSubEvent + { + } +}