在XAML Designer上,我希望my UserControl
(RepositoryContainer
)能够填充数据.
我创建了一个命名的文件RepositoryContainerDesignData.xaml
(它是在同一文件夹中RepositoryContainer.xaml
),并将其设置为d:DataContext
给UserControl
.
但是,XAML Designer不显示数据,而是显示属性名称.
这是一个最小的例子:
<local:RepositoryContainer xmlns:local="clr-namespace:SystemSpecs.View.UserControls"
Title="My Repository Title"
/>
Run Code Online (Sandbox Code Playgroud)
<UserControl x:Class="SystemSpecs.View.UserControls.RepositoryContainer"
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:SystemSpecs.View.UserControls"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="500"
d:DataContext="{d:DesignData Source=RepositoryContainerDesignData.xaml}"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<TextBlock Text="{Binding Path=Title}" FontSize="24" Foreground="White" HorizontalAlignment="Center" />
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
using System.Windows.Controls;
namespace SystemSpecs.View.UserControls
{
public partial class RepositoryContainer : UserControl
{
public string Title { get; set; }
public RepositoryContainer()
{
InitializeComponent();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正试图通过Google Chrome扩展程序控制Netflix的播放器.这是控制栏的图像,适用于那些不熟悉它的人.
我设法模拟点击播放/暂停,下一集并使用以下代码切换全屏按钮(橙色正方形):
$(".[control class]").click();
Run Code Online (Sandbox Code Playgroud)
但是同样的逻辑似乎并不适用于控制当前视频部分(蓝色矩形内部)的滑块.
我想要做的是改变视频的当前位置(例如,返回10秒).这是我到目前为止所尝试的:
更改aria-valuenow section role="slider"
:
$(".player-slider")["aria-valuenow"] = 0;
Run Code Online (Sandbox Code Playgroud)
检索红色圆圈,更改它的位置并单击它:
$(".player-scrubber-target")["style"] = "width: 30%";
$(".player-scrubber-target").click();
Run Code Online (Sandbox Code Playgroud)
(绝望)更改宽度和/或点击该部分内的每个栏:
.player-scrubber-progress-buffered (change width and click)
.player-scrubber-progress-completed (change width and click)
.player-scrubber-progress (click)
#scrubber-component (click)
Run Code Online (Sandbox Code Playgroud)
非常感谢Kodos Johnson指出了这个问题,并向kb0提供了原始代码,通过一些研究,我可以从Chrome开发者工具控制台更改音量和播放器位置.这是代码(更改所需音量0~99的[VOLUME]和所需位置的[POSITION]):
// Change volume
netflix.cadmium.UiEvents.events.resize[0].scope.events.dragend[0].handler(null, {pointerEventData: {drag: {current: {value: [VOLUME]}}}});
// Change player position
netflix.cadmium.UiEvents.events.resize[1].scope.events.dragend[1].handler(null, {value: [POSITION], pointerEventData: {playing: false}});
Run Code Online (Sandbox Code Playgroud)
不幸的是,这似乎不适用于Chrome开发者工具.当我从我的扩展程序运行代码片段时,我得到了这个:
Uncaught ReferenceError: netflix is not defined at <anonymous>:1:1
Run Code Online (Sandbox Code Playgroud)
这是我从我的扩展程序运行脚本的方式:
chrome.tabs.getSelected(null, function(tab){
chrome.tabs.executeScript(tab.id, {code: [SNIPPET]}, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个桌面应用程序,它将更新发送到我正在开发的网络服务。
理想情况下,应用程序只需配置一次并部署到网络共享。配置应用程序时,用户将输入用于在 Web 服务中进行身份验证的密码。之后,将创建一个令牌以用于将来的连接。
这将允许任何有权访问网络共享的计算机(即使它不是配置应用程序的计算机)只运行应用程序(将连接到 Web 服务),而无需输入任何凭据(因为令牌具有已被保存)。
以下是我尝试/思考过的一些事情:
使用 C# 之类的方法序列化令牌SecureString
并将其存储在文件中:这是我所拥有的最好的方法。但显然,如果有人获得了密钥文件的访问权限,则逆转非常简单。
这个答案建议使用Windows 数据保护 API (DPAPI)(在 C# 中,ProtectedData
该类),但显然,这将只允许最初保存凭据的用户访问它们,这是行不通的,因为我必须访问受保护的凭据。来自多个用户/设备的数据。
将令牌作为参数传递给应用程序:这只会更改我要存储令牌的位置(例如,在调用程序的批处理文件或操作系统任务上),但我认为它不再有效安全的。
using System.IO;
Directory.Delete("someFolder",true);
Directory.Create("someFolder");
Run Code Online (Sandbox Code Playgroud)
删除目录或删除目录后是否会执行第三行?我是否必须将第一个命令放入"任务"并等待它完成?
最近我在我的一个程序中实现了Squirrel.Windows 。它对于基本功能来说效果很好。
问题是主要方法都是内部的,我们无法使用扩展方法或执行我们自己的实现。另外,Squirrel 项目有太多未解决的问题,所以我认为这不是一个很好的项目。
是否有任何库具有类似的功能,但同时给我更多的控制权并让我使用已经实现的代码?
需要能够使用 WPF。
干杯
我想实现一个容器,其中包含可滚动的列表项目我正在使用图像设置换行面板的背景,但此图像根据换行面板的项目进行拉伸.我想修复背景,以便内容可以滚动,但不会拉伸背景图像.我使用以下代码.
<ScrollViewer x:Name="imageScrollViewer" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<WrapPanel x:Name="panel" Orientation="Horizontal" >
<WrapPanel.Background>
<VisualBrush>
<VisualBrush.Visual>
<Image Name="pnlBackground">
<Image.OpacityMask>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5" >
<GradientStop Offset="0.0" Color="#00000000" />
<GradientStop Offset="1.0" Color="#FF000000" />
</LinearGradientBrush>
</Image.OpacityMask>
</Image>
</VisualBrush.Visual>
</VisualBrush>
</WrapPanel.Background>
<ListBox
Margin="5"
SelectionMode="Extended"
ItemsSource="{Binding}"
SelectedIndex="0"
d:IsHidden="True">
</ListBox>
</WrapPanel>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud) 我正在创建一个应用程序,用户可以在其中通过我的 .NET 应用程序执行 PowerShell 命令。
我创建了以下方法:
public static string ExecutePowerShell(string cmd, out string errors)
{
StringBuilder output = new StringBuilder();
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddCommand(cmd);
Collection<PSObject> PSOutput = PowerShellInstance.Invoke();
foreach (PSObject obj in PSOutput)
{
output.AppendLine(obj.ToString());
}
errors = string.Join("\n", PowerShellInstance.Streams.Error.ReadAll());
}
return output.ToString();
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼它:
string errors = String.Empty;
ExecutePowerShell("cmd", out errors);
Run Code Online (Sandbox Code Playgroud)
如果我在 PowerShell 控制台中执行它,我会发现:
我的应用程序只是冻结。
这是重现问题的完整代码:Link to Pastebin for organization
*不要忘记添加对System.Management.Automation
程序集的引用(通常在C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0
)
在上面的代码中,我在两个 …
c# ×5
wpf ×3
.net ×2
clickonce ×1
css ×1
html ×1
javascript ×1
jquery ×1
netflix ×1
powershell ×1
wai-aria ×1
web-services ×1
xaml ×1