我创造了以下事件ListBox:
<ListBox x:Name="RecentItemsListBox" Grid.Row="1" BorderThickness="0" Margin="2,0,0,0" SelectionChanged="RecentItemsListBox_SelectionChanged">
<ListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}"
BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Style.Triggers>
<!--This trigger is needed, because RelativeSource binding can only succeeds if the current ListBoxItem is already connected to its visual parent-->
<Trigger Property="IsVisible" Value="True">
<Setter Property="HorizontalContentAlignment"
Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment"
Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,2,0,0">
<TextBlock Text="{Binding Number}" />
<StackPanel Orientation="Vertical" Margin="7,0,0,0">
<TextBlock Text="{Binding File}" />
<TextBlock Text="{Binding Dir}" …Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在C#中获取或使用内存
我想在我的应用程序的状态栏中可视化我的应用程序使用的内存.我正在寻找记忆漏洞 - 但我不知道在哪里.现在,我的想法是在状态栏中可视化使用的内存,以便在我使用应用程序时找到它,找到问题发生的部分,然后我可以对其进行分析.
有人可以给我一些帮助,我怎样才能得到用过的记忆.
我HttpGet在我的 Server-API 中创建了一个 CSV 文件并返回它FileStreamResult:
[HttpGet]
public IActionResult Get() {
// do logic to create csv in memoryStream
return new FileStreamResult(memoryStream, "text/csv;charset=utf-8") {
FileDownloadName = "products.csv",
};
}
Run Code Online (Sandbox Code Playgroud)
在我的 Blazor-Client 应用程序中,我创建了一个带有处理程序的按钮:
private async Task DownloadCatalog() {
var file = HttpClient.GetAsync("api/csvProduct");
// ... how do I download the file in the browser?
}
Run Code Online (Sandbox Code Playgroud)
调用了控制器中的 Get,但我不知道该怎么做才能在 api 调用后将文件下载到浏览器中。
我有一个WPF窗口,我没有关闭.相反,我做Hide()和Show()它.现在,当我在记录中的网格中双击我的MainWindow时,将触发Show()窗口,窗口将始终显示在MainWindow后面.我已经尝试了休息,但没有成功:
view.Show();
view.Activate();
view.Topmost = true;
view.Topmost = false;
view.Focus();
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以让窗户绝对到前面?我无法将MainWindow设置为所有者.
我有一个TreeView.现在,我想检测,如果垂直滚动条是否可见.我试试的时候
var visibility = this.ProjectTree.GetValue(ScrollViewer.VerticalScrollBarVisibilityProperty)
Run Code Online (Sandbox Code Playgroud)
(其中this.ProjectTree是TreeView)我总是获得Auto以获得可见性.
如果ScrollBar有效可见,我该如何检测?
谢谢.
我有一个带有属性字符串的UILabel.这是它的打印屏幕:

现在,我必须将这个属性字符串翻译成英语和意大利语.我正在寻找一种方法来做到这一点.我可以逐个代码地在代码中构建这个属性字符串吗?我只找到了一个解决方案,其中设置了整个字符串,然后通过范围设置属性.但是当我翻译字符串时,我不再知道范围,因为这些字词更长或更小.
我有一个WPF窗口,我只创建一次,然后多次Show()和Hide().现在我正在寻找一种方法来将焦点设置在每个Show()上的元素上.我在哪里以及如何做到这一点?
可能重复:
背景工人在午夜时检查?
是否有一个我可以注册的SystemEvent,它将在午夜发布,当日期发生变化时?
为什么在下面的示例中第一个(x)为真,第二个(y)为假?我想在C#中使用类似VB的运算符.
Dim x = "abc@symas-design.ch" Like "*symas-design.ch"
Dim y = Microsoft.VisualBasic.CompilerServices.Operators.LikeString("abc@symas-design.ch", "*symas-design.ch", CompareMethod.Text)
Run Code Online (Sandbox Code Playgroud) 当我执行以下代码时
System.Net.ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => {
return true;
};
var webClient = new WebClient();
var s = webClient.DownloadString("https://jtlplugins.x-volution.de/api.php?apikey=yS5VS7OiG1ukiIqLzCSYuFCjeF1qSskKOQeCtVxh&do=pruefe_app&cappid=123&chardwareid=DC0D-BFEA-6F79-58DE-21E9-BA3A-B288-C46F&clizenzschluessel=123");
Run Code Online (Sandbox Code Playgroud)
我总是得到一个System.Net.WebException:无法创建SSL/TLS安全通道
当我执行这个
https://jtlplugins.x-volution.de/api.php?apikey=yS5VS7OiG1ukiIqLzCSYuFCjeF1qSskKOQeCtVxh&do=pruefe_app&cappid=123&chardwareid=DC0D-BFEA-6F79-58DE-21E9-BA3A-B288-C46F&clizenzschluessel=123
Run Code Online (Sandbox Code Playgroud)
例如,直接在Firefox或Internet Explorer中,它可以工作并返回结果.
我应该怎么做,这也是我的代码在浏览器中执行的?
我已经阅读了stackoverflow中有关此问题的其他帖子 - 但他们没有解决我的问题:-(
c# ×7
wpf ×4
.net ×3
asp.net-core ×1
blazor ×1
c#-4.0 ×1
ios ×1
listbox ×1
listboxitem ×1
localization ×1
memory-leaks ×1
scrollviewer ×1
setfocus ×1
ssl ×1
vb.net ×1
webclient ×1
window ×1
xaml ×1
xcode ×1