有没有内置的东西System.IO.Path只给我文件路径?
例如,如果我有 string
@ "C:\网络服务器\ PUBLIC\myCompany的\ CONFIGS\promo.xml"
是否有任何BCL方法可以给我
"C:\网络服务器\ PUBLIC\myCompany的\ CONFIGS \"?
无论按钮状态如何,我都试图显示工具提示,但这似乎没有办法:
<Button Command="{Binding Path=CommandExecuteAction}"
ToolTip="{Binding Path=Description}" ToolTipService.ShowOnDisabled="true"
Style="{StaticResource toolbarButton}">
<Image Source="{Binding Path=Icon}"></Image>
</Button>
Run Code Online (Sandbox Code Playgroud)
如果由于command.CanExecute返回false而禁用按钮时如何显示工具提示?
注意:
ToolTipService.ShowOnDisabled ="true"就像一个魅力.这在我的示例中不起作用的原因是因为与按钮关联的样式重新定义了控件模板,并在禁用按钮时关闭按钮上的命中测试(IsHitTestVisible = false).重新启用controltemplate中的命中测试,使按钮被禁用时显示工具提示.
每次我尝试为blob创建容器时都会出现异常
使用以下代码
CloudStorageAccount storageAccInfo;
CloudBlobClient blobStorageType;
CloudBlobContainer ContBlob;
blobStorageType = storageAccInfo.CreateCloudBlobClient();
//then I initialize storageAccInfo
ContBlob = blobStorageType.GetContainerReference(containerName);
//everything fine till here ; next line creates an exception
ContBlob.CreateIfNotExist();
Run Code Online (Sandbox Code Playgroud)
Microsoft.WindowsAzure.StorageClient.StorageClientException was unhandled
Message="One of the request inputs is out of range."
Source="Microsoft.WindowsAzure.StorageClient"
StackTrace:
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry[T](Func`2 impl, RetryPolicy policy)
at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist(BlobRequestOptions options)
at Microsoft.WindowsAzure.StorageClient.CloudBlobContainer.CreateIfNotExist()
at WebRole1.BlobFun..ctor() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 58
at WebRole1.BlobFun.calling1() in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\WebRole1\BlobFun.cs:line 29
at AzureBlobTester.Program.Main(String[] args) in C:\Users\cloud\Documents\Visual Studio 2008\Projects\CloudBlob\AzureBlobTester\Program.cs:line 19
at …Run Code Online (Sandbox Code Playgroud) 我有一个ListBox,最初显示时选择了第一个项目.我希望它显示没有选择任何项目.这可能吗?
谢谢
<ComboBox Grid.Row="1" Grid.Column="0" Width="Auto" Name="cmbBudgetYear">
<ComboBoxItem Content="2009" />
<ComboBoxItem Content="2010" />
<ComboBoxItem Content="2011" />
<ComboBoxItem Content="2012" />
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
如何在后面的代码中将所选项目设置为当前年份?
就像是...
cmbBudgetYear.SelectedItem = cmbBudgetYear.Items(
get the item with the Now.Year.ToString)
Run Code Online (Sandbox Code Playgroud) 我将如何构造下面的代码,以便调用异步方法?
Parallel.For(0, elevations.Count(), delegate(int i)
{
allSheets.AddRange(await BuildSheetsAsync(userID, elevations[i], includeLabels));
});
Run Code Online (Sandbox Code Playgroud) 我正在考虑为Min,Max等基本数学运算编写泛型函数.但是我不知道如何比较两种泛型类型:
public T Max<T>(T v1, T v2) where T: struct
{
return (v1 > v2 ? v1 : v2);
}
Run Code Online (Sandbox Code Playgroud)
那个怎么样?
谢谢.
我有:
WriteableBitmap bmp;
Run Code Online (Sandbox Code Playgroud)
我基本上想将它保存到磁盘上的文件中,如下所示:
C:\bmp.png
Run Code Online (Sandbox Code Playgroud)
我读了一些提到阅读的论坛:
bmp.Pixels
Run Code Online (Sandbox Code Playgroud)
并将这些像素保存到Bitmap当时使用的Bitmap.SaveImage()函数中.但是,我无法访问任何Pixels.显然我的WriteableBitmap名字没有任何属性Pixels.
我使用.NET Framework 4.0.
我正在尝试设置我的第一个WPF ListView/GridView,并且无法设置列标题的样式.我目前有3个问题.以下是GridView的视图:
替代文字http://img195.imageshack.us/img195/3245/wpfgridview.png
我想删除分隔列标题的小白色垂直边框.
我想删除MouseOver效果.此屏幕截图将鼠标悬停在第3列上,将背景变为白色.
如何在不将其拧紧的情况下覆盖单个列上的水平对齐?
这就是代码的样子:
<Style x:Key="GrayHeader" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.0" Color="#373638" />
<GradientStop Offset="1.0" Color="#57595B" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="5, 5" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
<ListView ItemsSource="{Binding Source={StaticResource
EmployeeInfoDataSource}}"
Margin="0,20,0,20">
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}" >
<Setter Property="Height" Value="24" />
<Setter Property="Background" Value="#7BB3DC" />
<Setter Property="Foreground" Value="#000000" />
<Setter Property="FontSize" Value="12" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="BorderThickness" Value="1" /> …Run Code Online (Sandbox Code Playgroud) 我有一个显示客户信息的窗口.当窗口加载时,我LoadCustomer()从构造函数调用方法,该构造函数异步加载来自数据库的客户信息,这将设置CurrentCustomer属性.然后更新UI,因为它绑定到CurrentCustomer.
private void LoadCustomer(Guid customerID)
{
var customerContext = new CustomerContext();
var customerQuery = customerContext.GetCustomersQuery()
.Where(e => e.CustomerID == customerID);
customerContext.Load(customerQuery,
loadOperation =>
{
CurrentCustomer = loadOperation.Entities.SingleOrDefault();
}, null);
}
Run Code Online (Sandbox Code Playgroud)
高级程序员告诉我,最好把这个逻辑放在CurrentCustomer的get访问器中,因为那时候
将异步数据库调用放在属性的get访问器中是一种好习惯吗?
c# ×6
wpf ×4
.net ×2
async-await ×1
asynchronous ×1
azure ×1
combobox ×1
database ×1
file ×1
gridview ×1
math ×1
path ×1
properties ×1
silverlight ×1
windows ×1
winforms ×1