首次上传
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<UserControl x:Class="SicUI.Client.Dialog.ItemsSelectDialogView"
|
||||
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:SicUI.Client.Dialog"
|
||||
mc:Ignorable="d"
|
||||
xmlns:ts="clr-namespace:OpenSEMI.ClientBase.Command;assembly=MECF.Framework.UI.Client"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid SnapsToDevicePixels="True">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="350"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DataGrid Name="SequenceFileList" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" AutoGenerateColumns="False" CanUserAddRows="False"
|
||||
ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedName}" Width="315" Height="416">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Name" Width="200" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding }" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<ts:CommandSource.Trigger>
|
||||
<ts:CommandTriggerGroup>
|
||||
<ts:EventCommandTrigger RoutedEvent="DataGrid.MouseDoubleClick" CustomParameter="{Binding SelectedItem,ElementName=SequenceFileList}"
|
||||
Command="{Binding DataContext.ListViewDoubleClick,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
|
||||
</ts:CommandTriggerGroup>
|
||||
</ts:CommandSource.Trigger>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
|
||||
<Button Content="Select" Command="{Binding SelectCommand}" HorizontalAlignment="Left" Height="35" Width="80" />
|
||||
<Button Content="Cancel" Command="{Binding CancelCommand}" HorizontalAlignment="Left" Height="35" Width="80" Margin="5,0,0,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SicUI.Client.Dialog
|
||||
{
|
||||
/// <summary>
|
||||
/// ItemsSelectDialogView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ItemsSelectDialogView : UserControl
|
||||
{
|
||||
public ItemsSelectDialogView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
using OpenSEMI.ClientBase;
|
||||
using OpenSEMI.ClientBase.Command;
|
||||
|
||||
namespace SicUI.Client.Dialog
|
||||
{
|
||||
public class ItemsSelectDialogViewModel : DialogViewModel<string>
|
||||
{
|
||||
#region properties
|
||||
private string _SelectedName;
|
||||
public string SelectedName
|
||||
{
|
||||
get { return _SelectedName; }
|
||||
set { _SelectedName = value; }
|
||||
}
|
||||
|
||||
public ObservableCollection<string> Items { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Command
|
||||
private ICommand _BtnSelectCommand;
|
||||
public ICommand SelectCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._BtnSelectCommand == null)
|
||||
this._BtnSelectCommand = new BaseCommand<EventCommandParameter<object, RoutedEventArgs>>((EventCommandParameter<object, RoutedEventArgs> arg) => this.OnSelectCommand(arg));
|
||||
return this._BtnSelectCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _BtnCancelCommand;
|
||||
public ICommand CancelCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._BtnCancelCommand == null)
|
||||
this._BtnCancelCommand = new BaseCommand<EventCommandParameter<object, RoutedEventArgs>>((EventCommandParameter<object, RoutedEventArgs> arg) => this.OnCancelCommand(arg));
|
||||
return this._BtnCancelCommand;
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _ListViewDoubleClick;
|
||||
public ICommand ListViewDoubleClick
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ListViewDoubleClick == null)
|
||||
this._ListViewDoubleClick = new BaseCommand<EventCommandParameter<object, RoutedEventArgs>>((EventCommandParameter<object, RoutedEventArgs> arg) => this.OnListViewDoubleClick(arg));
|
||||
return this._ListViewDoubleClick;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Function
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
this.DisplayName = "Select Dialog";
|
||||
}
|
||||
|
||||
private void OnSelectCommand(EventCommandParameter<object, RoutedEventArgs> arg)
|
||||
{
|
||||
DialogResult = SelectedName;
|
||||
IsCancel = false;
|
||||
TryClose(true);
|
||||
}
|
||||
|
||||
private void OnListViewDoubleClick(EventCommandParameter<object, RoutedEventArgs> arg)
|
||||
{
|
||||
if (arg != null)
|
||||
{
|
||||
this.DialogResult = SelectedName;
|
||||
IsCancel = false;
|
||||
TryClose(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancelCommand(EventCommandParameter<object, RoutedEventArgs> arg)
|
||||
{
|
||||
IsCancel = true;
|
||||
TryClose(false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user