This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="MktSys.Gui.HierarchicalDataTemplateTreeViewItemEventSettingWindos" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="HierarchicalDataTemplate な TreeViewItem にイベントを設定する" Height="525" Width="300"> | |
<Grid> | |
<TreeView Name="treeView" ItemsSource="{Binding Elements}" VerticalContentAlignment="Stretch"> | |
<TreeView.ItemContainerStyle> | |
<Style TargetType="{x:Type TreeViewItem}"> | |
<EventSetter Event="MouseDoubleClick" Handler="treeViewItem_MouseDoubleClick" /> | |
</Style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows; | |
using System.Windows.Media; | |
namespace MktSys.Lib.Extensions | |
{ | |
/// <summary> | |
/// DependencyObject 拡張メソッドクラス | |
/// </summary> | |
public static class DependencyObjectExtension | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C# キーワード定義ファイル | |
// CASE=True | |
#endif | |
#endregion | |
#if | |
#pragma | |
#region | |
abstract | |
as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HierarchicalDataTemplate を使用して、様々な TreeItemViewModelBase を継承したクラスを含むツリーでのドラッグアンドドロップを想定。 | |
// typeof で実際にドラッグされたアイテムの Type を指定できないため、ホルダーを作成している。 | |
/// <summary> | |
/// 最後に左クリックした座標 | |
/// </summary> | |
private Point lastLeftMouseButtonDownPoint; | |
/// <summary> | |
/// ドラッグアンドドロップ開始基準となる距離 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows.Controls.Primitives; | |
this.dataGrid.Items.ForEach<DataGridRowViewModel>(viewModel => | |
{ | |
var dataGridRow = this.dataGrid.ItemContainerGenerator.ContainerFromItem(viewModel) as DataGridRow; | |
var cellsPresenter = dataGridRow.FindVisualChild<DataGridCellsPresenter>(); | |
var cell = cellsPresenter.ItemContainerGenerator.ContainerFromItem(viewModel) as DataGridCell; | |
var presenter = cell.Content as ContentPresenter; | |
var dbOutputValueTextBox = presenter.ContentTemplate.FindName("valueTextBox", presenter) as TextBox; | |
viewModel.Value = valueTextBox.Text; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PreviewDragOver で捕まえないとダメ | |
/// <summary> | |
/// TextBox ドラッグオーバー時処理<br /> | |
/// 対象のアイテムならば受け入れる。 | |
/// </summary> | |
/// <param name="sender">発生元</param> | |
/// <param name="e">引数</param> | |
private void textBox_PreviewDragOver(object sender, DragEventArgs e) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// コントロールキーあるいはシフトキーが押されているかどうかを取得する | |
/// </summary> | |
private bool IsCtrlOrShiftKeyPressed | |
{ | |
get | |
{ | |
return (Keyboard.GetKeyStates(Key.LeftShift) & KeyStates.Down) == KeyStates.Down || | |
(Keyboard.GetKeyStates(Key.RightShift) & KeyStates.Down) == KeyStates.Down || | |
(Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) == KeyStates.Down || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ContextMenu ItemsSource="{Binding Menus}"> | |
<ContextMenu.ItemContainerStyle> | |
<Style TargetType="{x:Type MenuItem}"> | |
<Setter Property="Header" Value="{Binding Title}" /> | |
<Setter Property="Command" Value="{Binding Command}" /> | |
<Setter Property="IsEnabled" Value="{Binding IsEnabled}" /> | |
<Style.Triggers> | |
<DataTrigger Binding="{Binding IsSeparator}" Value="True"> | |
<Setter Property="Template"> | |
<Setter.Value> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Native | |
{ | |
[Flags] | |
public enum ExtendedWindowStyles | |
{ | |
WS_EX_TOOLWINDOW = 0x80 | |
} | |
public enum GetWindowLongFields | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// System.Windows.Forms と System.Drawing を参照設定に追加する必要がある。 | |
// この例では通知ウィンドウを右下に表示させるというシナリオ | |
/// <summary> | |
/// 通知ウィンドウ表示時の画面からのマージン | |
/// </summary> | |
private const int NOTIFICATION_WINDOW_DISPLAY_MARGIN = 5; | |
/// <summary> | |
/// 指定のメッセージをユーザーに知らせるダイアログを表示する。 |