小编Jas*_*ska的帖子

WPF Border IsMouseOver触发器无法正常工作

我在app.xaml中定义了这种样式:

    <Style x:Key="RedCloseButton" TargetType="Border">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Border.Background" Value="Yellow" />
                </Trigger>
                <Trigger Property="IsMouseOver" Value="False">
                    <Setter Property="Border.Background" Value="Black" />
                </Trigger>
            </Style.Triggers>
    </Style>
Run Code Online (Sandbox Code Playgroud)

而我正试图在另一个xaml -file中使用它,如下所示:

    <Border Style="{StaticResource RedCloseButton}" Name="ClearValue" BorderThickness="2" BorderBrush="black" CornerRadius="0,4,4,0" Margin="110,90,0,80" Background="#FF801F1F">                
            <Rectangle Margin="10,11,6,10" Fill="White" RadiusX="2" RadiusY="2" IsHitTestVisible="False"></Rectangle>
    </Border>
Run Code Online (Sandbox Code Playgroud)

但当我将鼠标移到边境时没有任何反应......这里可能有什么问题?

wpf xaml

9
推荐指数
1
解决办法
8205
查看次数

启用父操作时,WPF TouchUp不会触发

我有一个画布,有一个儿童控制.子控件接收所有PreviewTouchDown和PreviewTouchUp事件 - 但在IsManipulationEnabledCanvas上启用Manipulation(= true)后,只有"down"事件会在子对象上触发,但TouchUp和PreviewTouchUp事件根本不会触发.

有什么想法在这里发生了什么?

wpf touch

6
推荐指数
1
解决办法
7764
查看次数

适用于Windows 8的WPF性能监视器

我正在尝试监控/找到我的WPF应用程序的最大性能瓶颈,我一直在谷歌搜索的所有地方都在说"安装WPFPerf.msi",但要安装它,我应该首先安装Windows SDK 7.1,但在Windows 8上安装失败.

WPFPerf已从Windows 8 SDK工具包中删除.

那么有没有适用于Windows 8的WPF性能监控工具?

wpf performance windows-8

6
推荐指数
1
解决办法
1354
查看次数

当DataGridView.SelectionMode为FullRowSelect时,剪贴板复制失败

在Windows窗体中,如果我创建一个包含几行和列的简单DataGridView控件,然后将SelectionMode属性设置为FullRowSelect,我会使用剪贴板的复制功能获得奇怪的行为:

当选择一行并且用户点击ctrl-c时,整个行将被复制到剪贴板,单元格之间有\ t \n字符,如预期的那样.

当用户双击并编辑单个单元格时,在该单元格内部用户选择文本的一部分并点击ctrl-c,STILL将复制整行,而不是所选文本的部分!

作为一种解决方法,我尝试在keydown事件上执行剪贴板复制,但是当编辑控件处于编辑模式时不会触发事件.

有什么建议?

c# datagridview winforms

3
推荐指数
1
解决办法
2002
查看次数

WCF和ref参数

我遇到了WCF的奇怪问题,并将参数作为ref传递.

假设我有一个班级:

Class MyClass 
{
     public string str;
}
Run Code Online (Sandbox Code Playgroud)

和这样的代码块:

List<MyClass> c = new List<MyClass>();
c.Add(new MyClass());
MyClass c2 = c[0];
Run Code Online (Sandbox Code Playgroud)

如果我然后调用应该更新该类的str属性的WCF方法:

WCFService.UpdateStr(ref c2);
Run Code Online (Sandbox Code Playgroud)

c [0]和c2是不同的 - 它们不应该在str属性中包含相同的字符串!?通过ref函数参数在WCF中有什么问题吗?

c# wcf

1
推荐指数
1
解决办法
1660
查看次数

当放置在另一个ScrollViewer中时,WPF TreeView不显示滚动条

我有一个问题,当TreeView放置在具有ScrollViewer的容器内时,TreeView的滚动条不起作用,而是调整容器的ScrollViewer的内容,以便所有TreeView项都可见.

在WinForms中我可以设置容器的最小内容宽度和高度,但是如何在WPF中实现这一点?

这是XAML的示例:

<Window x:Class="TestWpfTreeViewInsideScrollViewer.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <ScrollViewer Name="scroll1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >
        <Grid MinHeight="230" MinWidth="200" Grid.IsSharedSizeScope="True">
            <Button Content="Button" Width="74" Height="52" Margin="10,24,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
            <Button Content="Button" Height="52" Margin="89,24,10,0" VerticalAlignment="Top"/>
            <Button Content="Button" Width="74" Height="52" Margin="10,81,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>

            <TreeView Margin="10,138,10,55">
                <TreeViewItem IsExpanded="True" Header="This is a long text but the treeview is not scrolling">
                    Instead the TreeView is expanding its size to fit all these nodes inside it, i want that the upper scroller take in only when grid minwidth …
Run Code Online (Sandbox Code Playgroud)

wpf treeview scrollviewer

1
推荐指数
1
解决办法
3297
查看次数

当有两个嵌套的using子句时,Microsoft.usage警告

我想知道为什么Visual Studio代码分析会用这一小段代码发出警告:

byte[] data = File.ReadAllBytes("myImage.png");
using (MemoryStream mem = new MemoryStream(data))
using (Bitmap bmp = new Bitmap(mem))            
{
     // do something with the bitmap
}
Run Code Online (Sandbox Code Playgroud)

错误是:

对象'mem'可以在方法中多次处理...为避免生成System.ObjectDisposedException,不应在对象上多次调用Dispose.

以及如何纠正这个?(是的,我可以直接从文件中加载位图,但在我的真实项目中,我有自己的文件格式,其中多个图像保存到一个文件中,因此我需要MemoryStream从文件中的特定范围加载数据)

c#

0
推荐指数
1
解决办法
270
查看次数

标签 统计

wpf ×4

c# ×3

datagridview ×1

performance ×1

scrollviewer ×1

touch ×1

treeview ×1

wcf ×1

windows-8 ×1

winforms ×1

xaml ×1