AlexSJC 的博客

WPF MVVM 中 ItemsControl 内绑定外层 DataContext

方法一:通过 ElementName 绑定外层控件的 DataContext。 {Binding DataContext.×××, ElementName=×××} 方法二:通过 RelativeSource 绑定外层控件的 DataContext。 {Binding DataContext.×××

AlexSJC AlexSJC 发布于 2024-08-31

C# 单例应用

https://www.nuget.org/packages/Asjc.SingletonApp

AlexSJC AlexSJC 发布于 2024-02-03

C# 各类方式获取应用程序路径

步骤 ConsoleApp1 调用 ClassLibrary1 的方法。 在 CMD 运行,输出的内容如下图所示。 归纳即可得到下表。

AlexSJC AlexSJC 发布于 2024-01-24

Xamarin.Android 更好地管理通知渠道

NotificationHelper using Android.Content; using Android.OS; using System.Reflection; public static class NotificationHelper { public static void

AlexSJC AlexSJC 发布于 2024-01-12

WPF 文件图标转换器

using System; using System.Drawing; using System.Globalization; using System.IO; using System.Windows; using System.Windows.Data; using System.Windows

AlexSJC AlexSJC 发布于 2024-01-01

C# UniqueWindow

using System.Collections.Generic; using System.Windows; public class UniqueWindow { private static readonly List<Window> windows = new(); pu

AlexSJC AlexSJC 发布于 2023-12-14

WPF 工具窗口

更改指定窗口的属性。 函数还将指定偏移量的 32 位 (长) 值设置为额外的窗口内存。 https://learn.microsoft.com/zh-cn/windows/win32/api/winuser/nf-winuser-setwindowlonga

AlexSJC AlexSJC 发布于 2023-12-12

Xamarin.Android 请求忽略电池优化

<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { Powe

AlexSJC AlexSJC 发布于 2023-11-12

Xamarin.Android 前台服务

public const string CHANNEL_ID = "default_channel"; public const string CHANNEL_NAME = "Default Channel"; public const int NOTIFICATION_ID = 10000; p

AlexSJC AlexSJC 发布于 2023-11-10

C# 异步 Ping 多个 IP

public static async Task<List<string>> PingIPs(List<string> ips, int timeout = 1000) { var tasks = ips.Select(ip => new Ping().SendPingAsync(ip, t

AlexSJC AlexSJC 发布于 2023-10-21

WPF 重写语言实现本地化

添加这段代码(Application_Startup): FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(

AlexSJC AlexSJC 发布于 2023-10-17

Xamarin.Android 绑定服务

https://www.nuget.org/packages/Asjc.Android.ServiceHelper

AlexSJC AlexSJC 发布于 2023-08-12

C# 模拟按键

public class KeySim { [DllImport("user32.dll")] private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

AlexSJC AlexSJC 发布于 2023-06-24

C# MiniTimer

https://www.nuget.org/packages/Asjc.MiniTimer

AlexSJC AlexSJC 发布于 2023-06-19

Window Sharing Hider

Hides Windows during screen sharing. Works with Teams, Zoom, Discord, etc. Single app, no dll’s, works on both x86/x64 Relies on SetWindowDisplayAffin

AlexSJC AlexSJC 发布于 2023-05-01

C# AesHelper

using System; using System.Security.Cryptography; using System.Text; public class AesHelper { public static string Encrypt(string text, string ke

AlexSJC AlexSJC 发布于 2023-04-30

WPF 自定义属性

<Window x:Name="window" ...> <Grid> <TextBlock Text="{Binding Text, ElementName=window}" /> </Grid> </Window> public static readonly D

AlexSJC AlexSJC 发布于 2023-04-24

C# JsonConfig

https://www.nuget.org/packages/Asjc.JsonConfig

AlexSJC AlexSJC 发布于 2023-04-21