我有Xamarin Forms xaml:
// MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BlankAppXamlXamarinForms"
x:Class="BlankAppXamlXamarinForms.MainPage">
<Label Text="{Binding myProperty}" />
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
我有代码背后:
// MainPage.xaml.cs
namespace BlankAppXamlXamarinForms {
public partial class MainPage : ContentPage
{
public string myProperty= "MY TEXT";
public MainPage()
{
InitializeComponent();
BindingContext = this;
}
}
}
Run Code Online (Sandbox Code Playgroud)
它应该将myProperty绑定到标签的文本.但是,标签中没有显示任何内容.如何将myProperty绑定到标签的文本?(我知道我应该使用ViewModel来通知视图有关属性的更改,但在这个例子中我真的只想将myProperty从代码绑定到标签)
如何强制 Windows 与 UWP 应用中使用的 BLE 设备断开连接?我收到来自某些特征的通知,但在某些时候我想停止接收它们并确保我与 BLE 设备断开连接以节省 BLE 设备的电池?
在 Window 7、8 和 10 上,我希望我的应用程序将数据存储在共享位置,以便在 PC 上运行该应用程序的所有用户都可以访问相同的数据。数据是可读/可写的。我应该使用什么位置?
我的.h文件:
template <typename T>
class UpdateUtils
{
public:
typedef struct {
QList<T> file;
} TPath;
static TPath *getIdealPath(QList<TPath *> &paths);
};
Run Code Online (Sandbox Code Playgroud)
我的.cpp文件:
template <typename T>
TPath *UpdateUtils<T>::getIdealPath(QList<TPath *> &paths) {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这会在cpp文件中产生错误:
Run Code Online (Sandbox Code Playgroud)error: C2143: syntax error : missing ';' before '*' error: C2065: 'T' : undeclared identifier error: C2923: 'UpdateUtils' : 'T' is not a valid template type argument for parameter 'T'
如果我TPath *用例如替换返回类型int,它可以工作.你能给些建议么?
我正在尝试使用iTextSharp填写AcroForm的文本字段.Acroform文本字段也是由iTextSharp通过这段代码创建的:
TextField Field = new TextField(OutputWriter, FieldPos, "MyField");
OutputWriter.AddAnnotation(Field.GetTextField()); // OutputWriter is writing to form.pdf
Run Code Online (Sandbox Code Playgroud)
我使用以下代码填写表单:
PdfReader reader = new PdfReader("form.pdf");
PdfStamper filledOutForm = new PdfStamper(reader, new FileStream("filled_form.pdf", FileMode.Create));
AcroFields form = filledOutForm.AcroFields;
form.SetField("MyField", "some unicode data");
Run Code Online (Sandbox Code Playgroud)
但是,当我在Acrobat Reader中打开filled_form.pdf时,除非我手动编辑字段(例如,我手工将字符附加到字段),否则unicode字符不可见.
我也尝试通过以下方式设置字段的字体:
BaseFont fieldFontRoman = BaseFont.CreateFont(@"C:\Windows\Fonts\times.ttf",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
form.SetFieldProperty("MyField", "textfont", fieldFontRoman, null);
Run Code Online (Sandbox Code Playgroud)
然后,当我在Acrobat Reader中打开filled_form.pdf时,除非我手动编辑该字段,否则一切看起来都很好.之后,非unicode字符消失(它们变为空格).他们在这里是因为如果我通过CTRL + C复制字段的整个内容并将其粘贴到记事本,我可以看到所有字符.
请指教.我希望看到该字段中的所有字符,而无需手动编辑字段,当然在手动编辑后我希望没有字符消失.
谢谢
我刚购买了搭载 Android 10 的华为 MatePad T8 平板电脑。我启用了开发者选项,我可以通过 micro USB 线对其进行调试。
我想设置无线调试。我杀死 adb 服务器,关闭 Android Studio 并使用 USB 电缆连接我的设备。然后我发出命令:
adb tcpip 5555
adb connect 192.168.1.14:5555
Run Code Online (Sandbox Code Playgroud)
我将我的两个 adb 设备(相同的设备,但一次通过 USB 电缆,第二个是无线调试)成功连接到我的 PC:
adb devices
List of devices attached
8TU9X20428K01472 device
Run Code Online (Sandbox Code Playgroud)
然后我断开 USB 电缆,然后我得到:
adb devices
List of devices attached
192.168.1.14:5555 offline
Run Code Online (Sandbox Code Playgroud)
无论我重复这个过程多少次,我总是让我的设备脱机,而且我无法进行无线调试。平板电脑的 wifi 工作正常(我可以浏览网页)。您能建议如何在华为MatePad T8上启用无线调试吗?仅供参考:在我手中的任何设备上启用无线调试从来没有遇到过任何问题。
我使用 PackageInstaller 和 PackageInstaller.Session 从我的应用程序安装应用程序。我想在安装失败时在我的应用程序中显示一条消息(例如,如果 apk 签名错误)。我如何获得安装会话的结果?
我尝试连接到BLE外围设备。首先,我看广告:
watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;
watcher.Start();
Run Code Online (Sandbox Code Playgroud)
在WatcherOnReceived回调中,我尝试创建BluetoothLEDevice
public async void WatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs btAdv)
{
BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromBluetoothAddressAsync(btAdv.BluetoothAddress);
}
Run Code Online (Sandbox Code Playgroud)
但是,我总是在WatcherOnReceived回调中得到bleDevice == null。为什么以及如何解决?在UWP应用程序中创建BLE设备的正确方法是什么?然后,我需要连接到该设备,发现其GATT服务和特性,在其中一些上启用通知,并读/写其中一些。
这是用于获取BLE设备的UWP代码。为什么某些设备会出现bleDevice == null?我没有找到任何说明这一点的文档。
var devices = await DeviceInformation.FindAllAsync(BluetoothLEDevice.GetDeviceSelector());
foreach (DeviceInformation di in devices)
{
Debug.WriteLine(di.Name);
BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromIdAsync(di.Id);
if (bleDevice == null) {
Debug.WriteLine("--- NULL ----");
continue;
}
Debug.WriteLine(bleDevice.Name);
}
Run Code Online (Sandbox Code Playgroud)
我注意到对于Windows设备管理器中带有STATUS_DEVICE_POWER_FAILURE带有感叹号的BLE设备,我得到bleDevice!= null。
对于设备管理器中没有感叹号的BLE设备,我得到bleDevice == null。