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 ListViewHelper | |
{ | |
public static int GetIndex(object item) | |
{ | |
if (item is not ListViewItem listViewItem) | |
return -1; | |
ListView listView = (ListView)ItemsControl.ItemsControlFromItemContainer(listViewItem); | |
return listView.ItemContainerGenerator.IndexFromContainer(listViewItem); | |
} |
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; | |
using System.Runtime.InteropServices; | |
public enum Direction { None, TopLeft, TopRight, BottomRight, BottomLeft } | |
public static class WindowHelper | |
{ | |
public static Direction GetAvailableDirection(IntPtr windowHandle) | |
{ | |
if (!GetWindowRect(windowHandle, out RECT buffer)) |
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; | |
using System.Windows; | |
using Windows.System; | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} |
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.Controls; | |
using Microsoft.Xaml.Behaviors; | |
public class ContextMenuBehavior : Behavior<ContextMenu> | |
{ | |
protected override void OnAttached() | |
{ | |
base.OnAttached(); |
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 partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
private async void Button_Click(object sender, RoutedEventArgs e) | |
{ | |
await Task.Run(async () => |
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
<Style x:Key="ListViewStyle" TargetType="{x:Type ListView}"> | |
<Setter Property="ItemContainerStyle"> | |
<Setter.Value> | |
<Style TargetType="{x:Type ListBoxItem}"> | |
<Setter Property="Foreground" Value="Black"/> | |
<Style.Triggers> | |
<MultiDataTrigger> | |
<MultiDataTrigger.Conditions> | |
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsFocused}" Value="True"/> | |
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=IsKeyboardFocusWithin}" Value="True"/> |
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 static class IdleTime | |
{ | |
[DllImport("User32.dll")] | |
private static extern bool GetLastInputInfo(ref LASTINPUTINFO info); | |
private struct LASTINPUTINFO | |
{ | |
public uint cbSize; | |
public uint dwTime; | |
} |
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
<SolidColorBrush x:Key="ProgressBar.Background" Color="#FFE6E6E6"/> | |
<SolidColorBrush x:Key="ProgressBar.Progress" Color="#FF1C61F3"/> | |
<SolidColorBrush x:Key="ProgressBar.Stripe" Color="#33FFFFFF"/> | |
<Style x:Key="StripedProgressBarStyle" TargetType="{x:Type ProgressBar}"> | |
<Setter Property="Background" Value="{StaticResource ProgressBar.Background}"/> | |
<Setter Property="Foreground" Value="{StaticResource ProgressBar.Progress}"/> | |
<Setter Property="Height" Value="20"/> | |
<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
<Window x:Class="WpfFontGlyph.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" | |
SizeToContent="Height" Height="100" Width="480"> | |
<StackPanel> | |
<Grid Margin="10"> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="1*"/> | |
<ColumnDefinition Width="1*"/> |
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
private class S | |
{ | |
public bool Enabled { get; } | |
public S(bool enabled) => Enabled = enabled; | |
} | |
static void Main(string[] args) | |
{ | |
M(new S(true)); |