小编Kri*_*rip的帖子

WPF工具包DataGridCell样式DataTrigger

如果在DataGrid中更新了值,我试图将单元格的颜色更改为黄色.

我的XAML:

<toolkit:DataGrid x:Name="TheGrid"
                  ItemsSource="{Binding}"
                  IsReadOnly="False"
                  CanUserAddRows="False"
                  CanUserResizeRows="False"
                  AutoGenerateColumns="False"
                  CanUserSortColumns="False"                             
                  SelectionUnit="CellOrRowHeader" 
                  EnableColumnVirtualization="True" 
                  VerticalScrollBarVisibility="Auto"
                  HorizontalScrollBarVisibility="Auto">
    <toolkit:DataGrid.CellStyle>
        <Style TargetType="{x:Type toolkit:DataGridCell}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsDirty}" Value="True">
                    <Setter Property="Background" Value="Yellow"/>
                 </DataTrigger>
            </Style.Triggers>
        </Style>
    </toolkit:DataGrid.CellStyle>
</toolkit:DataGrid>
Run Code Online (Sandbox Code Playgroud)

网格绑定到数组列表(显示类似于excel的值表).数组中的每个值都是一个包含IsDirty依赖项属性的自定义对象.更改值时,将设置IsDirty属性.

当我运行这个:

  • 更改第1列中的值=整行变为黄色
  • 更改任何其他列中的值=没有任何反应

我希望只有更改的单元格变为黄色,无论它在哪个列中.你看到我的XAML有什么问题吗?

c# wpf datagrid datatrigger wpftoolkit

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

不要将光标更改为TextBox

我试图让TextBox看起来像一个TextBlock给用户(它在树视图中,我想允许重命名).我能够通过应用样式将边框和背景设置为透明,并将IsReadOnly属性设置为true来实现此目的.我唯一的问题是鼠标光标仍然从指针样式变为编辑(插入符号)样式.是否有一种简单的方法来禁用它(最好是在xaml中)?

c# wpf textbox mouse-cursor

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

将不透明度应用于LinearGradientBrush

我有一个LinearGradientBrush定义如下.我想在我的xaml中使用它,但我想在这种特殊情况下改变不透明度(仅在这种情况下,不是我使用它的任何地方).任何想法如何实现这一目标?

 <LinearGradientBrush x:Key="BlueBackgroundBrush" EndPoint="0.874,1.197" StartPoint="0.126,-0.197">
    <GradientStop Color="#1954B2" />
    <GradientStop Color="#1954B2" Offset="0.982" />
    <GradientStop Color="#FF84B2D4" Offset="0.304" />
</LinearGradientBrush>
Run Code Online (Sandbox Code Playgroud)

c# wpf lineargradientbrush brushes

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

使用XmlSerializer进行自定义序列化

我有一个类,我需要从中做一些自定义XML输出,因此我实现了IXmlSerializable接口.但是,我想要使用默认序列化输出的一些字段,除了我想要更改xml标记名称.当我调用serializer.Serialize时,我在XML中获得了默认的标记名称.我能以某种方式改变这些吗?

这是我的代码:

public class myClass: IXmlSerializable
{
    //Some fields here that I do the custom serializing on
    ...

    // These fields I want the default serialization on except for tag names
    public string[] BatchId { get; set; }
    ...

    ... ReadXml and GetSchema methods are here ...

    public void WriteXml(XmlWriter writer)
    {                        
        XmlSerializer serializer = new XmlSerializer(typeof(string[]));
        serializer.Serialize(writer, BatchId);
        ... same for the other fields ...

        // This method does my custom xml stuff
        writeCustomXml(writer);   
    }

    // My custom xml …
Run Code Online (Sandbox Code Playgroud)

c# xml-serialization ixmlserializable .net-3.5

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

MessageBoxButtons中"否"和"取消"之间的区别

当用户去删除项目并最初使用MessageBoxButtons.YesNoCancel时,我使用MessageBox显示确认消息.后来我改为YesNo,因为用户指出在这种情况下"No"和"Cancel"没有真正的区别.我的问题是......有什么区别?是否有理由使用YesNoCancel而不是YesNo?

c# messagebox

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