我正在尝试使用 WPFToolkit 中的网格,但收到错误:
DisplayDataMapping.xaml (9,89):
errorMC1000: Unknown build error,
'Could not load type 'System.Windows.Controls.Primitives.MultiSelector' from assembly
'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Line 9 Position 89.'
Run Code Online (Sandbox Code Playgroud)
这是 xaml:
<UserControl x:Class="显示数据映射"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit">
<StackPanel边距=“10”>
<Border CornerRadius =“5”BorderThickness =“1”填充=“5”BorderBrush =“WhiteSmoke”>
<工具包:DataGrid x:名称=“dataGridPostings”背景=“透明”
AlternatingRowBackground="LightSteelBlue" RowBackground="白色"
GridLinesVisibility="无" HorizontalGridLinesBrush="SlateGray">
</工具包:数据网格>
</边框>
</堆栈面板>
</用户控制>
请记下这个使用 Microsoft Visual Studio 2008 编写的小型 WPF C# 程序的代码:
.xaml
<Window x:Class="WpfDatagridTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="Window1" Height="300" Width="300">
<Grid>
<WpfToolkit:DataGrid
x:Name="DataGrid_" ItemsSource="{Binding}"
SelectionMode="Extended"
CanUserAddRows="False" CanUserDeleteRows="False"
CanUserResizeRows="False" CanUserSortColumns="False"
AutoGenerateColumns="False"
RowHeaderWidth="17" RowHeight="25" />
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
。CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Windows.Controls;
namespace WpfDatagridTest
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window …Run Code Online (Sandbox Code Playgroud) 我正在使用RowDetailsTemplate显示行的嵌套数据网格.现在,当我选择一行来显示这个嵌套的数据网格时,数据网格的高度会扩展.但是当取消选择行时,它不会降低其高度.
有没有办法在折叠行详细信息后将数据网格大小调整为原始高度?
是否有可能以声明方式进行?
我使用WPF工具包datagrid来显示一些数据,并希望增加每行的水平girdlines的厚度,我会认为这将是一件简单的事情,但我找不到解决方案.
我试图提供一个 DataGrid 列,它的行为类似于 DataGridTextColumn,但在编辑模式下有一个附加按钮。我查看了 DataGridTemplateColumn,但将 DataGridTextColumn 子类化似乎更容易,如下所示
问题是 textBox 在添加到网格时失去了它的绑定。也就是说,对其 Text 属性的更改不会反映在非编辑 TextBlock 或底层视图模式中
关于为什么会这样以及我如何解决它的任何想法?
public class DataGridFileColumn : DataGridTextColumn
{
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem)
{
TextBox textBox = (TextBox)base.GenerateEditingElement(cell, dataItem);
Button button = new Button { Content = "..." };
Grid.SetColumn(button, 1);
return new Grid
{
ColumnDefinitions = {
new ColumnDefinition(),
new ColumnDefinition { Width = GridLength.Auto },
},
Children = {
textBox,
button,
},
};
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 .NET 3.5 和 WPF 工具包
我正在使用扩展 WPF 工具包。
https://wpftoolkit.codeplex.com/wikipage?title=TimeSpanUpDown
当我单击箭头时,默认情况下它会增加 hours 的值。
有没有办法让它首先增加秒数作为默认行为?
我使用Xceed WPF Toolkit 的 Wizard Control构建了一个包含多个页面的向导,并且我需要程序知道当前活动的页面,以便能够确定必要的步骤。
我正在尝试绑定CurrentPage到 ViewModel,如下所示:
XAML:
<xctk:Wizard CurrentPage="{Binding CurrentStep, Mode=TwoWay}">
<xctk:WizardPage Name="Import">
...
</xctk:WizardPage>
...
</xctk:Wizard>
Run Code Online (Sandbox Code Playgroud)
视图模型:
public WizardPage CurrentStep { get; set; }
Run Code Online (Sandbox Code Playgroud)
问题是CurrentStep总是返回Null并且向导只显示一个空白页。
需要做什么才能CurrentPage使用 MVVM 返回活动向导页面?
我是WPF的新手,ScrollViewer令我很沮丧.或者我只是不"得到"它,或者它是一个有限的控制.
这是我的挫折:
水平滚动错误水平滚动条仅在列表底部可见(我必须滚动到底部才能看到它)
坏边框我的ScrollViewer中有一个ListBox.当我开始列表的底部没有边框时,当我向下滚动时,列表框的顶部边框(行)消失.我可以理解这一点,但尝试为ScrollViewer设置BorderThickness或BorderBrush结果没有变化(我想使用ScrollViewer的边框在列表内容周围保留一个常量框,就像网络世界中的大多数列表框一样).
短列表处理不当当列表中的项目未到达底部时,ScrollViewer会将滚动条保留在那里并将其抖动.为什么不释放一些空间并将其删除?
其中一些可能看起来很小(而且它们是).但是用户期望从他们的应用程序中获得一定的外观和感觉,而WPF则很难将其开箱即用.
如果你知道如何解决这些问题,我会很乐意回应.如果有一个更好的方法来处理滚动比使用ScrollViewer,欢迎.
我正在使用WPF工具包,我正在尝试渲染一个看起来像直方图的图形.特别是,我希望每列都与每个列相对应.列之间应该没有间隙.
创建列图时,您应用了许多组件.(参见下面的示例XAML).有没有人知道你是否可以在其中一个元素上设置属性,这些元素指的是列之间的空白宽度?
<charting:Chart Height="600" Width="Auto" HorizontalAlignment="Stretch" Name="MyChart"
Title="Column Graph" LegendTitle="Legend">
<charting:ColumnSeries
Name="theColumnSeries"
Title="Series A"
IndependentValueBinding="{Binding Path=Name}"
DependentValueBinding="{Binding Path=Population}"
Margin="0"
>
</charting:ColumnSeries>
<charting:Chart.Axes>
<charting:LinearAxis
Orientation="Y"
Minimum="200000"
Maximum="2500000"
ShowGridLines="True" />
<charting:CategoryAxis
Name="chartCategoryAxis"
/>
</charting:Chart.Axes>
</charting:Chart>
Run Code Online (Sandbox Code Playgroud) 当我第一次打开使用wpf工具包日期选择器的窗口时,今天的日期在日历中突出显示,但相关文本框中没有任何内容(期望水印为mm/dd/yyy).
我想在用户选择日期并"提交"之后将日期选择重置为该初始状态,以便当他们再次使用它时,不是在他们之前选择的日期.因此,例如,如果一个人从现在起2个月后选择了一个日期,那么当它被重置时,文本框是mm/dd/yyyy水印,当日历打开时,它以今天的日期作为"开始日期"开始.
我尝试了以下各种组合,但这不会重置文本:
//set date to today so it move the calendar to this date
mydatepicker.SelectedDate = DateTime.Now;
//reset since we don't want a date selected
mydatepicker.SelectedDate = null;
//reset the text
mydatepicker.Text = string.Empty;
Run Code Online (Sandbox Code Playgroud)
如果我仅重置文本,则不会重置日历(所选日期\开始).但是,如果我设置日历,文本会更新,而不仅仅是水印.
有任何想法吗?
谢谢
wpf ×10
wpftoolkit ×10
c# ×5
datagrid ×3
wpfdatagrid ×2
.net ×1
cell ×1
charts ×1
data-binding ×1
datepicker ×1
datetime ×1
graph ×1
mvvm ×1
scrollviewer ×1
timespan ×1
uiscrollview ×1
wizard ×1
wpf-controls ×1
xaml ×1