是否可以将自动对焦设置为我的xaml文件中的文本框?
<Window x:Class="WpfApplication1.Views.Test1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="100"
Width="210"
WindowStartupLocation="CenterOwner"
ShowInTaskbar="False"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
ResizeMode="CanResizeWithGrip">
<TextBox HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" TextWrapping="Wrap" AcceptsReturn="True" Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Window>
Run Code Online (Sandbox Code Playgroud) 当按钮被禁用时,我希望灰显我的图像(在按钮上).当我在按钮上有文本(没有图像)时,文本显示为灰色(将图像作为按钮内容,它们不会变灰).有没有简单而美丽的方法呢?
这是我的xaml文件:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ToolBarTray VerticalAlignment="Top" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" IsLocked="true" Grid.Row="0">
<ToolBar Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Band="1" BandIndex="1">
<Button Command="{Binding Button1}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
<Button Command="{Binding Button2}" RenderOptions.BitmapScalingMode="NearestNeighbor">
<Button.Content>
<Image Source="open.ico"></Image>
</Button.Content>
</Button>
</ToolBar>
</ToolBarTray>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
这是我的代码隐藏文件:
public partial class MainWindow : Window
{
private RelayCommand _button1;
private RelayCommand _button2;
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
public ICommand Button1
{
get
{ …
Run Code Online (Sandbox Code Playgroud) 我在我的个人Libs中使用WPF UserControl.Libs包含在我的WPF和WindowsForms程序中.现在我的UserControl必须显示一个新的(WPF)窗口.在新窗口我想设置所有者.我是这样做的:
dialog.Owner = Application.Current.MainWindow;
Run Code Online (Sandbox Code Playgroud)
如果我在WPF程序中使用UserControl,这可以正常工作.
当我在我的WindowsForms程序中使用UserControl时(我在ElementHost中设置UserControl elementHost.Child = ...
)为Application.Current
null.
这不好,我的程序抛出异常.
为什么是Application.Current
null?
我试图将一些HTTP请求从我的angular.js应用程序发送到服务器,但是我需要解决一些CORS错误。
使用以下代码发出HTTP请求:
functions.test = function(foo, bar) {
return $http({
method: 'POST',
url: api_endpoint + 'test',
headers: {
'foo': 'value',
'content-type': 'application/json'
},
data: {
bar:'value'
}
});
};
Run Code Online (Sandbox Code Playgroud)
第一次尝试以一些CORS错误结束。因此,我在PHP脚本中添加了以下几行:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, X-Auth-Token, content-type');
Run Code Online (Sandbox Code Playgroud)
现在消除了第一个错误。
现在,Chrome的开发者控制台向我显示以下错误:
angular.js:12011选项http:// localhost:8000 / test(匿名函数)
423ef03a:1 XMLHttpRequest无法加载 http:// localhost:8000 / test。飞行前的响应具有无效的HTTP状态代码400
并且网络请求看起来像我预期的那样(HTTP状态400
也是预期的):
我无法想象如何解决问题(以及如何理解),为什么请求将在localhost OPTIONS
和上发送到远程服务器POST
。有解决方案如何解决这个奇怪的问题?
我写了扩展方法GenericExtension
.现在我想调用扩展方法Extension
.但是值methodInfo
始终为null.
public static class MyClass
{
public static void GenericExtension<T>(this Form a, string b) where T : Form
{
// code...
}
public static void Extension(this Form a, string b, Type c)
{
MethodInfo methodInfo = typeof(Form).GetMethod("GenericExtension", new[] { typeof(string) });
MethodInfo methodInfoGeneric = methodInfo.MakeGenericMethod(new[] { c });
methodInfoGeneric.Invoke(a, new object[] { a, b });
}
private static void Main(string[] args)
{
new Form().Extension("", typeof (int));
}
}
Run Code Online (Sandbox Code Playgroud)
怎么了?
我有以下样式定义:
<!-- Border -->
<Style x:Key="MyControlBorder" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="DarkKhaki" />
<Setter Property="Background" Value="White" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="10" />
</Style>
<!-- TextBox -->
<Style x:Key="MyTextBox" TargetType="{x:Type TextBox}">
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBoxBase}">
<Border Name="TextBoxBorder" Style="{StaticResource MyControlBorder}">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- PasswordBox -->
<Style x:Key="MyPasswordBox" TargetType="{x:Type PasswordBox}">
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<Border Name="Border" Style="{StaticResource MyControlBorder}">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</Setter.Value> …
Run Code Online (Sandbox Code Playgroud) 我有一本需要排序的字典.我知道字典无法排序,所以我正在构建一个列表来执行基于索引的排序.我遇到的问题是多个键上有重复的值; 此外,值可以是多个列表.
字典:
my_dict = {
'1' : ['Red', 'McDonald\'s'],
'2' : [['Orange', 'Wendy\'s'], ['Purple', 'Cookout']],
'3' : ['Yellow', 'Longhorn'],
'4' : ['Green', 'Subway'],
'5' : ['Blue', 'Chipotle'],
'6' : ['Indigo', 'Taco Bell'],
'7' : [['Violet', 'Steak n Shake'], ['Dark Red', 'Five Guys']],
'8' : ['Dark Orange', 'Wendy\'s'],
'9' : ['Aqua', 'Firehouse Subs'],
'10' : ['Magenta', 'McDonald\'s'],
}
Run Code Online (Sandbox Code Playgroud)
我需要能够通过键(数字),颜色和餐厅对其进行排序.我遇到的问题是,当存在重复时,必须对打印进行分组,而我无法弄清楚如何对我正确生成的列表进行排序.
按编号打印的示例:
1:
Red, McDonald's
2:
Orange, Wendy's
Purple, Cookout
3:
Yellow, Longhorn
...
Run Code Online (Sandbox Code Playgroud)
按颜色打印的示例:
Aqua:
Firehouse Subs, 9
Blue:
Chipotle, 5 …
Run Code Online (Sandbox Code Playgroud) 我已将一些文件添加到我的 nuxt 项目中。文件存储在./content
目录中。现在我们收到了一些警告,如下所示:
WARN in ./content/config.yml
Module parse failed: Unexpected token (9:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Run Code Online (Sandbox Code Playgroud)
为了防止出现错误,我尝试排除nuxt.config.js
. 我添加了以下几行,但警告并没有消失。
build: {
/*
** You can extend webpack config here
*/
extend (config, ctx) {
config.module.rules.push({
test: /\.yml$/,
exclude: [
path.resolve(__dirname, '/content/config.yml')
]
}
)
}
}
Run Code Online (Sandbox Code Playgroud)
还有其他选项可以防止出现警告吗?
我正在查看其他人写过的表格验证码,我看到了这个:
strlen() == 0
Run Code Online (Sandbox Code Playgroud)
在测试表单变量是否为空时,我使用该empty()
函数.有一种方式比另一种更好吗?它们在功能上是否相同?
我有一个GIT-Repo里面有我所有的模块.我想使用Composer将它们包含在我的不同项目中.有没有办法将它们全部放在一个git仓库中,还是我需要为每个模块创建一个自己的GIT-Repo?
wpf ×3
xaml ×3
php ×2
angularjs ×1
autofocus ×1
button ×1
c# ×1
command ×1
composer-php ×1
cors ×1
dictionary ×1
elementhost ×1
generics ×1
git ×1
http ×1
image ×1
javascript ×1
loops ×1
methodinfo ×1
nuxt.js ×1
passwordbox ×1
python ×1
python-3.x ×1
sorting ×1
strlen ×1
styles ×1
textbox ×1
vue.js ×1
webpack ×1
windows ×1
winforms ×1