我有一个ContentTemplate自定义控件来显示子控件.数据上下文没有通过我的DataTemplate,因此当我绑定我的子控件时,我无法检索该值.我很确定我没有特别针对DataTemplate实现这一点,所以我将不胜感激任何帮助.我已经把问题分解成尽可能小的情况.
一,页面:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<ResourceDictionary>
<local:MainWindowViewModel x:Key="ViewModel" />
</ResourceDictionary>
</Window.Resources>
<Grid DataContext="{StaticResource ViewModel}">
<local:MyControl>
<local:MyControl.MainContent>
<DataTemplate>
<TextBlock Text="{Binding TextValue}" />
</DataTemplate>
</local:MyControl.MainContent>
</local:MyControl>
</Grid>
Run Code Online (Sandbox Code Playgroud)
接下来,ViewModel:
Public Class MainWindowViewModel
Implements INotifyPropertyChanged
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Private _textValue As String
Public Property TextValue() As String
Get
If String.IsNullOrEmpty(_textValue) Then
_textValue = "A default value"
End If
Return _textValue
End Get
Set(ByVal value As String)
_textValue = value …Run Code Online (Sandbox Code Playgroud) 我有一个SQL数据库,里面有几百个表,但我只需要处理几个.有没有办法在SQL Server Management Studio 2008中隐藏大部分表格?另一种选择是创建某种只能引用我感兴趣的表的分组.过滤表有效,但是我无法添加OR逻辑运算符来包含多个条件.
谢谢,马特
我正在使用IListBlobItems列表CloudBlobContainer.ListBlobs.然后我使用以下代码循环遍历每个条目以显示blob的大小:
foreach (IListBlobItem item in blobs)
{
if (item.GetType() == typeof(CloudBlobDirectory))
{ }
else if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blockBlob = (CloudBlockBlob)item;
IEnumerable<ListBlockItem> blocks = blockBlob.DownloadBlockList(new BlobRequestOptions { BlobListingDetails = BlobListingDetails.All });
Console.WriteLine(blockBlob.Name.PadRight(50, ' ') +
blocks.Sum(b => b.Size));
}
else
{
Console.WriteLine(item.Uri.LocalPath);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我检查变量的计数时blocks,它始终为0.为什么?
我正在尝试了解Azure Service Bus上的重试策略,但是它没有按我期望的方式工作。我有以下代码,它们既侦听消息,又将消息发送到特定的天蓝色队列。
using System;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
namespace ServiceBusTester
{
class Program
{
static void Main(string[] args)
{
var connectionString = "Endpoint=sb://<NamespaceName>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<SharedAccessKey>";
var queueName = "MyTestQueue";
var retryPolicy = new RetryExponential(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(30), 15);
var ns = NamespaceManager.CreateFromConnectionString(connectionString);
ns.Settings.RetryPolicy = retryPolicy;
if (!ns.QueueExists(queueName))
ns.CreateQueue(queueName);
var mf = MessagingFactory.CreateFromConnectionString(connectionString);
mf.RetryPolicy = retryPolicy;
var mr = mf.CreateMessageReceiver(queueName);
mr.RetryPolicy = retryPolicy;
var retryCount = 0;
mr.OnMessage(_ =>
{
retryCount++;
Console.WriteLine($"{retryCount.ToString().PadLeft(4, ' ')} - Message Received: {_.GetBody<string>()}");
_.Abandon();
}, new OnMessageOptions() { AutoComplete …Run Code Online (Sandbox Code Playgroud)