我正在研究WPF,我正在设计一个包含数据格的控制器, 并且一切都进展顺利。
但有些奇怪的事情刚刚发生:如果我在数据网格中显示一个或多个行, 数据网格在结尾处显示空行用来添加新行, 通常如此, 但是如果数据网格中没有行, 则也没有显示空行!
所以,我需要我的数据格 总是在末端的空行 不论数据是否。
我尝试了 CanUserAddRows 和
IsRead only
的属性,但正如我之前所说,只有当有一个或多个行时才有效。
有人知道如何做到这一点吗?
提前感谢您
我正在研究WPF,我正在设计一个包含数据格的控制器, 并且一切都进展顺利。
但有些奇怪的事情刚刚发生:如果我在数据网格中显示一个或多个行, 数据网格在结尾处显示空行用来添加新行, 通常如此, 但是如果数据网格中没有行, 则也没有显示空行!
所以,我需要我的数据格 总是在末端的空行 不论数据是否。
我尝试了 CanUserAddRows 和
IsRead only
的属性,但正如我之前所说,只有当有一个或多个行时才有效。
有人知道如何做到这一点吗?
提前感谢您
您的意思是空白行吗? 请查看 < a href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
此基本设置确实显示一个空白行( 即使被约束的项目源没有数据)
XAML XAML
<Window x:Class="Demo.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"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
>
<Grid>
<DataGrid ItemsSource="{Binding Items}">
<!--Must define columns if you need columns before bound collection has data-->
<DataGrid.Columns>
<DataGridTextColumn Header="Property" Binding="{Binding Path=MyProperty}"> </DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
后面的守则
public class Data
{
public Data(string value) { MyProperty = value; }
public Data() { } // Must have default constructor
public String MyProperty { get; set; }
}
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
List<Data> _items = new List<Data>();
public List<Data> Items
{
get { return _items; }
}
public MainWindow()
{
InitializeComponent();
}
I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...
Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...
I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...
Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...
Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...
I ve got some code which sets up a datacontext. Often enough, the datacontext should be set to some underlying data collection, such as an ObservableCollection - but occasionally I d like to set it ...
I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...
NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...