编程技术分享 - 2024年7月
type: channel
link: https://www.codespool.com/index.php/2024/07/
description: Your description here.
items: WPF_分隔按钮
items: WPF_实现拖放文件_MvvmLight
items: WPF_UpdateSourceTrigger

WPF_分隔按钮
type: item
date: 2024-07-28T22:20:00+08:00
description: <Button.Template> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Button.Template> <Button.Template> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Button.Template>

WPF_实现拖放文件_MvvmLight
type: item
date: 2024-07-28T00:17:00+08:00
description: NuGet添加库引用： 确保项目中已经添加了 System.Windows.Interactivity 和 MvvmLightLibsxmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:command="http://www.galasoft.ch/mvvmlight" AllowDrop="True" <i:Interaction.Triggers> <i:EventTrigger EventName="DragEnter"> <command:EventToCommand Command="{Binding DragEnterAndOverCommand}" PassEventArgsToCommand="True"/> </i:EventTrigger> <i:EventTrigger EventName="DragOver"> <command:EventToCommand Command="{Binding DragEnterAndOverCommand}" PassEventArgsToCommand="True"/> </i:EventTrigger> <i:EventTrigger EventName="Drop"> <command:EventToCommand Command="{Binding DropCommand}" PassEventArgsToCommand="True"/> </i:EventTrigger> <i:EventTrigger EventName="DragLeave"> <command:EventToCommand Command="{Binding DragLeaveCommand}" PassEventArgsToCommand="True"/> </i:EventTrigger> </i:Interaction.Triggers> <Border Grid.ColumnSpan="2" Background="#80808080" Visibility="{Binding IsImport}"/> // 是否正在拖放图片 private string _isImport = "Collapsed"; public string IsImport { get => _isImport; set => Set(ref _isImport, value, nameof(IsImport)); } public RelayCommand<DragEventArgs> DragEnterAndOverCommand { get; private set; } public RelayCommand<DragEventArgs> DropCommand { get; private set; } public RelayCommand<DragEventArgs> DragLeaveCommand { get; private set; } // 拖拽进入、移动 DragEnterAndOverCommand = new RelayCommand<DragEventArgs>(DragEnterAndOver); // 拖拽放入 DropCommand = new RelayCommand<DragEventArgs>(Drop); // 拖拽离开 DragLeaveCommand = new RelayCommand<DragEventArgs>(DragLeave); // 拖拽进入、移动 private void DragEnterAndOver(DragEventArgs e) { // 检查拖入的数据是否为文件类型 if (e.Data.GetDataPresent(DataFormats.FileDrop)) { IsImport = "Visible"; e.Effects = DragDropEffects.Copy; // 显示复制的鼠标样式 } else { IsImport = "Collapsed"; e.Effects = DragDropEffects.None; // 显示禁止的鼠标样式 } e.Handled = true; } // 拖拽放入 private void Drop(DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { try { // 获取拖放的所有文件路径 string[] selectFiles = (string[])e.Data.GetData(D…

WPF_UpdateSourceTrigger
type: item
date: 2024-07-01T23:19:00+08:00
description: <TextBox Text="{Binding SaveHeight, UpdateSourceTrigger=PropertyChanged}" Width="70" Grid.Column="1" Margin="5 0 0 0" Style="{StaticResource TextBoxExtend}" />