快问.我在WPF中配置了一个验证器,用于检查以确保值在特定范围内.这非常有效.见下面的代码:
<TextBox Name="valueTxt" Style="{StaticResource SquareBox}" GotKeyboardFocus="amountTxt_GotKeyboardFocus" GotMouseCapture="amountTxt_GotMouseCapture" LostFocus="boxLostFocus" Height="25" Width="50">
<TextBox.Text>
<Binding Path="UnitCost" NotifyOnValidationError="True">
<Binding.ValidationRules>
<local:ValidDecimal MaxAmount="1000"></local:ValidDecimal>
</Binding.ValidationRules>
<Binding.Converter>
<local:CurrencyConverter addPound="False" />
</Binding.Converter>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
但是,我想从验证者那里传递另一段数据.我假设我可以将它添加到验证器的演示中,如下所示:
<local:ValidDecimal MaxAmount="1000" SKU="{Binding Path=tblProducts.ProductSKU}"></local:ValidDecimal>
Run Code Online (Sandbox Code Playgroud)
但是,似乎我无法以这种方式访问SKU值.
有什么建议?
谢谢,
编辑值得指出的是,SKU只是在我的验证器中声明的字符串,如下所示:
public class ValidDecimal : ValidationRule
{
public int MaxAmount { get; set; }
public string SKU { get; set; }
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
//validate the value as a decimal in to two decimal places
string cost = (string)value;
try
{ …Run Code Online (Sandbox Code Playgroud) 我有一个ProgressBarWindow,它有一个进度条和一个取消按钮,我用它来报告文件I/O的进度.但是,尽管在后台工作中完成了所有工作,但ProgressBarWindow的UI线程和我的主窗口都会挂起.进度条呈现,就像我的主窗口一样,但是在后台工作人员执行其操作时不会更新.在主窗口的构造函数的最后调用以下代码:
iCountLogLinesProgressBar = new ProgressBarWindow();
iCountLogLinesProgressBar.cancelButton.Click += EventCountLogLinesProgressBarCancelButtonClicked;
iCountLogLinesProgressBar.Show();
iCountLogRecords = new BackgroundWorker();
iCountLogRecords.DoWork += EventCountLogLinesDoWork;
iCountLogRecords.ProgressChanged += EventCountLogLinesProgressChanged;
iCountLogRecords.RunWorkerCompleted += EventCountLogLinesRunWorkerCompleted;
iCountLogRecords.WorkerReportsProgress = true;
iCountLogRecords.WorkerSupportsCancellation = true;
iCountLogRecords.RunWorkerAsync(new BinaryReader(File.Open(iMainLogFilename, FileMode.Open, FileAccess.Read)));
Run Code Online (Sandbox Code Playgroud)
EventCountLogLinesProgressChanged()看起来像这样:
private void EventCountLogLinesProgressChanged(object sender, ProgressChangedEventArgs e)
{
iCountLogLinesProgressBar.Value = e.ProgressPercentage;
}
Run Code Online (Sandbox Code Playgroud)
这是ProgressBarWindow的缩短版本(其余只是几个setter):
public partial class ProgressBarWindow : Window
{
public ProgressBarWindow()
{
InitializeComponent();
this.progressBar.Value = this.progressBar.Minimum = 0;
this.progressBar.Maximum = 100;
}
public double Value
{
get
{
return progressBar.Value;
}
set
{
this.progressBar.Value = value;
} …Run Code Online (Sandbox Code Playgroud) 我的代码 -
if ($result)
{
$row = $result->fetch_object();
$filename = $row->src;
$q = "delete from photos WHERE id=$fileid";
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if ($result)
{
$filepath = "./images/";
if(fileDelete($filepath,$filename))
{
echo "success";
header("Location: index.php");
exit;
}
else echo "failed";
}
}
Run Code Online (Sandbox Code Playgroud)
输出 -
success Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\pics\deletepic.php:31) in C:\xampp\htdocs\pics\deletepic.php on line 32
我试图从我导入到我的wordpress数据库的表中提取数据.
我的PHP代码适用于所有默认的wp_表,但是当我尝试并定位表时,我实际上想让我回到bug.
我的代码(目前回复所有帖子标题,它的工作原理)
$liveposts = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->posts
WHERE post_status = 'publish'") );
foreach ($liveposts as $livepost) {
echo '<p>' .$livepost->post_title. '</p>';
}
Run Code Online (Sandbox Code Playgroud)
我从另一个数据库导入了3个表,是的,他们确实有数据要拔出.我发现$wpdb->posts期望post表是wp_posts ..所以我尝试将我的表重命名为wp_bus_route ...但仍然没有.
我使用phpMyAdmin从一个大型数据库(以.sql格式)导出3个表并导入它们.我可以在phpMyAdmin中查看表格并查看其中的所有数据.
这是我第一次从wp数据库中提取数据,所以我遗漏了一些明显的东西.
我在JavaScript中寻找一个不存在的修剪函数,Googling上的一些代码建议使用:
function trimStr(str) {
return str.replace(/^\s+|\s+$/g, '');
}
Run Code Online (Sandbox Code Playgroud)
我想知道它是如何str.replace(/^\s+|\s+$/g, '')
工作的.我知道这是某种形式的正则表达,但不知道它在做什么.
当我运行以下代码时,它会慢慢占用我的内存,甚至开始使用swap:
long long length = 1024ull * 1024ull * 1024ull * 2ull; // 2 GB
db = [NSMutableData dataWithLength:length];
char *array = [db mutableBytes];
for(long long i = 0; i < length - 1; i++) {
array[i] = i % 256;
}
Run Code Online (Sandbox Code Playgroud)
如果我在没有for循环的情况下运行它,则根本不使用内存:
long long length = 1024ull * 1024ull * 1024ull * 2ull;
db = [NSMutableData dataWithLength:length];
char *array = [db mutableBytes];
/* for(long long i = 0; i < length - 1; i++) {
array[i] = i % …Run Code Online (Sandbox Code Playgroud) 我们将在每个库中的Assembly.cs中找到Assembly版本.
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Run Code Online (Sandbox Code Playgroud)
我的问题是这是什么1.0.0.0意思?
谢谢
如何通过XSLT 将文件的doctype 干净地设置为HTML5 <!DOCTYPE html>(在本例中为collective.xdv)
以下是我最好的谷歌foo能够找到的:
<xsl:output
method="html"
doctype-public="XSLT-compat"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes" />
Run Code Online (Sandbox Code Playgroud)
生产:
<!DOCTYPE html PUBLIC "XSLT-compat" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Run Code Online (Sandbox Code Playgroud) 我是新手,并尝试使用OpenGL ES在我的iPhone屏幕上显示精灵.我知道使用cocos2d更简单,更容易,但现在我正在尝试直接在OpenGL上编码.是否有任何简单而有效的方法来加载和显示OpenGL ES中的精灵.到目前为止我发现的东西要复杂得多.:(