我是wpf的新手,并尝试将静态定义的DataGrid的Items.Count属性绑定到我的自定义控件的Label.
我目前的实现看起来像这样.但标签仍然是空的:我
定义DataGrid的类:
public class BindingNavigator : Control
{
private static DataGrid dataGrid;
static BindingNavigator()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(BindingNavigator), new FrameworkPropertyMetadata(typeof(BindingNavigator)));
}
public DataGrid DataGrid
{
set { dataGrid = value; }
get { return dataGrid; }
}
}
Run Code Online (Sandbox Code Playgroud)
CustomControl的XAML,其中Items.Count将显示在标签中
<Style TargetType="{x:Type local:BindingNavigator}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:BindingNavigator}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid MinWidth="210" MinHeight="50">
<Label Width="30" Height="30" Content="{Binding ElementName=DataGrid, Path=Items.Count}" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我部署自定义控件的XAML
<DataGrid Name="dataGrid1" VerticalAlignment="Top" Width="210">
<DataGrid.Columns>
<DataGridTextColumn Header="header" />
</DataGrid.Columns> …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚为什么以下代码不起作用,我假设使用char*作为键类型是一个问题,但是我不知道如何解决它或为什么它发生.我使用的所有其他功能(在HL2 SDK中)使用char*这样std::string会导致很多不必要的复杂化.
std::map<char*, int> g_PlayerNames;
int PlayerManager::CreateFakePlayer()
{
FakePlayer *player = new FakePlayer();
int index = g_FakePlayers.AddToTail(player);
bool foundName = false;
// Iterate through Player Names and find an Unused one
for(std::map<char*,int>::iterator it = g_PlayerNames.begin(); it != g_PlayerNames.end(); ++it)
{
if(it->second == NAME_AVAILABLE)
{
// We found an Available Name. Mark as Unavailable and move it to the end of the list
foundName = true;
g_FakePlayers.Element(index)->name = it->first;
g_PlayerNames.insert(std::pair<char*, int>(it->first, NAME_UNAVAILABLE));
g_PlayerNames.erase(it); // Remove name since …Run Code Online (Sandbox Code Playgroud) 我需要从对象中提取值,并且不确定如何实现它.
这是我的代码的精简版.谁能告诉我如何获得颜色?
var object = {
'fruit' : {
apple: {
goldenDelicious: [
{ color: 'green' }
]
}
}
}
Run Code Online (Sandbox Code Playgroud) 我试图在窗口的任何地方听鼠标点击(除了按钮的位置,但我稍后会处理),然后返回该位置的点(x,y).
这是相关代码:
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Console.WriteLine("mouseLeft is clicked");
Point x = e.MouseDevice.GetPosition(this);
Console.WriteLine(x.X);
Console.WriteLine(x.Y);
}
<Canvas MouseLeftButtonDown="Grid_MouseLeftButtonDown">
Run Code Online (Sandbox Code Playgroud)
当我点击时,没有打印任何内容.我究竟做错了什么?第一种方法在mainWindow.Xaml.cs中.
提前致谢.
我正在使用此处的doc为用户打印使用情况消息.有没有办法打印类似于unix上的手册页的特定单词BOLD.我在Unix上使用它.有没有办法在这里使用Term :: ANSIColor(或其他方式?)?
当我执行以下代码时; 我每次都会遇到一个段错误!这是一个已知的错误?如何使此代码有效?
<?php
$doc = file_get_contents("http://prairieprogressive.com/");
$replace = array(
"/<script([\s\S])*?<\/ ?script>/",
"/<style([\s\S])*?<\/ ?style>/",
"/<!--([\s\S])*?-->/",
"/\r\n/"
);
$doc = preg_replace($replace,"",$doc);
echo $doc;
?>
Run Code Online (Sandbox Code Playgroud)
错误(显然)看起来像:
[root@localhost 2.0]# php test.php
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
var test = {
a: 10,
b: 20,
c: (this.a+this.b)
};
Run Code Online (Sandbox Code Playgroud)
但它不起作用.如何从test.c中访问test.a?可能吗?
在我的工作场所,我们编写了一个自定义log4j appender,它将日志消息写入数据库(异步使用专用线程,因此没有性能损失).我更喜欢写入日志文件 - 基于数据库的日志更容易查询和分析.
是否有一个开源解决方案来执行此操作(特别是对于log4j或任何其他java记录器)?
我们的appender有一些东西,我希望在另一种方法中看到:
我们的appender支持以下列,我希望在我们找到的任何解决方案中看到所有这些列.