我有一个ScrollViewer:
<ScrollViewer Width="160"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Hidden"
Height="324" Canvas.Top="0"
BorderThickness="0" Padding="0">
<ListBox x:Name="Snapshots" SelectionChanged="Snapshots_SelectionChanged"
Padding="0" Background="#FFF0F0F0"
BorderBrush="{x:Null}" VerticalAlignment="Top"
SelectionMode="Single">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding imageSource}"
Margin="5" Stretch="UniformToFill"
Width="120" Opacity="0.2"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"
VerticalAlignment="Top" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ListBox>
</ScrollViewer>
Run Code Online (Sandbox Code Playgroud)
我该如何实现这些功能:
我正在尝试使用Windows Azure存储客户端库的v2.0为blob生成共享访问签名(并使用它).我从这个示例开始,但它是针对v1.7,并将其转换为2.0会产生404错误.
这是我的实际代码:服务器端,生成SAS:
var myAccount = CloudStorageAccount.Parse(
ConfigurationManager.ConnectionStrings[
"AzureStorageConnectionString"].ConnectionString);
var myContainer = myAccount.CreateCloudBlobClient()
.GetContainerReference(containerName);
myContainer.CreateIfNotExists();
string blobName = "Imports/" + DateTime.UtcNow.ToString("yyyy-MM-dd_HH-mm-ss")
+ ".zip";
var myBlob = myContainer.GetBlockBlobReference(blobName);
using (var stream =
new MemoryStream(System.Text.Encoding.UTF8.GetBytes("Hey, I'm empty for now.")))
{
myBlob.UploadFromStream(stream);
}
var sharedAccesSignature = myBlob.GetSharedAccessSignature(
new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy()
{
Permissions =
Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Write
| Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),
});
return myBlob.Uri.AbsoluteUri + sharedAccesSignature;
Run Code Online (Sandbox Code Playgroud)
它在客户端尝试了很多东西,有时导致404或403服务器错误.例如,我试过这个(结果:404):
var blobClient = new CloudBlobClient(new Uri(blobWithSharedAccessSignature));
// blobWithSharedAccessSignature here is : https://azertyuiop.blob.core.windows.net/container1/Imports/2012-12-01_19-43-54.zip?sv=2012-02-12&se=2012-12-01T20%3A43%3A54Z&sr=b&sp=rw&sig=h0bTUk[...]3D
// calling blobWithSharedAccessSignature …Run Code Online (Sandbox Code Playgroud) 环境:Win32,C/C++
所有三个(3)都可以用于线程向main()发信号通知它已经完成了一个操作.
但哪一个是所有人中最快的信号?
嗯...
我有一个WPF Windows应用程序.在一个窗口中有一个特定的堆栈面板,它保存一些用户数据.
我想打印出这个堆叠面板.
请建议?
我有一个带有列表框和内容控件的WPF应用程序.contentcontrol内容绑定到列表框,并具有一个datatemplate,显示一个文本框,其内容绑定到所述列表框中所选项的变量.到目前为止,一切运作良好,即当我从列表框中选择一个项目时,文本框内容会更改为变量的当前值.但是,如果在运行时我更改了变量的值,则文本框不会更新,除非我选择另一个列表框项目,然后再次选择原始项目.关于我做错了什么或者我在这里缺少什么的想法?我以为文本框的价值会自动改变?非常感谢您的帮助.
这是示例(MainWindow.xaml)
<Grid>
<ListBox Height="100" HorizontalAlignment="Left" Margin="12,105,0,0" x:Name="listBox1" VerticalAlignment="Top" Width="120" />
<ContentControl Height="120" HorizontalAlignment="Left" Margin="191,105,0,0" Name="contentControl1" VerticalAlignment="Top" Width="300" ContentTemplate="{DynamicResource MyDataTemplate}" Content="{Binding SelectedItem,ElementName=listBox1}"/>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="202,56,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
C#代码:
public MainWindow()
{
InitializeComponent();
listBox1.Items.Add(new MyItem(32));
listBox1.Items.Add(new MyItem(45));
listBox1.Items.Add(new MyItem(5));
}
private void button1_Click(object sender, RoutedEventArgs e)
{
((MyItem)listBox1.SelectedItem).Value = 4564654;
}
Run Code Online (Sandbox Code Playgroud)
额外课程:
public class MyItem
{
public MyItem(Int32 Value)
{
this.Value = Value;
}
public Int32 Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和模板:
我确定我遗漏了一些事情,比如通知UI来源的变化或以某种方式调用刷新.这是我的真实问题的更简化版本,其中包括控件和标签等,当源更改时必须刷新.干杯:)
c# ×2
wpf ×2
azure ×1
binding ×1
c ×1
datatemplate ×1
listbox ×1
postmessage ×1
sendmessage ×1
silverlight ×1
winapi ×1