我正在尝试使用 WPFToolkit 的 DataGrid 控件(和 C#/.Net 3.5)来显示每个记录的 ComboBox。使用以下代码,组合框会显示,但其下拉列表不包含任何项目:
<wpftkit:DataGrid ItemsSource="{Binding TransactionToEdit.SisterTransactions}"
AutoGenerateColumns="False">
<wpftkit:DataGrid.Columns>
<wpftkit:DataGridComboBoxColumn Header="Account" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type StackPanel}, diagnostics:PresentationTraceSources.TraceLevel=High}, Path=DataContext.Accounts}" DisplayMemberPath="Name"/>
</wpftkit:DataGrid.Columns>
</wpftkit:DataGrid>
Run Code Online (Sandbox Code Playgroud)
此外,Visual Studio 的输出窗口显示以下错误:
System.Windows.Data Error: 4 : Cannot find source for binding with
reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.StackPanel', AncestorLevel='1''.
BindingExpression:Path=DataContext.Accounts; DataItem=null; target element is
'DataGridComboBoxColumn' (HashCode=25733404); target property is
'ItemsSource' (type 'IEnumerable')
Run Code Online (Sandbox Code Playgroud)
但是,以下代码按预期工作(组合框的下拉列表已正确填充):
<ItemsControl ItemsSource="{Binding TransactionToEdit.SisterTransactions}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type StackPanel}}, Path=DataContext.Accounts, diagnostics:PresentationTraceSources.TraceLevel=High}" DisplayMemberPath="Name"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
请注意,DataGrid 和 ItemsControl 都具有相同的 ItemsSource 字符串。DataGridComboBoxColumn 和 ComboBox …
我想为当前具有焦点的 DataGrid 行设置边框。但不是选定的行,因为当为数据网格启用多重选择时,有可能选择多行。
我需要 XAML 解决方案
提前致谢!
有没有办法突出显示 a 上所有修改的行DataGrid?由于网格绑定到 aSystem.Data.DataTable我想我也许能够将每行的颜色绑定到它RowState(下面的示例),但这似乎不起作用。
有任何想法吗?
xmlns:data="clr-namespace:System.Data;assembly=System.Data"
<Style x:Key="DataGridRowStyle" TargetType="{x:Type toolkit:DataGridRow}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" Value="Blue" />
</Trigger>
<DataTrigger Binding="{Binding RowState}"
Value="{x:Static data:DataRowState.Modified}">
<Setter Property="Background" Value="LightYellow" />
</DataTrigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud) 有没有办法在图表上标记轴?
<charting:Chart Name="EventAlertsChart" BorderThickness="0" Margin="0,10,0,0">
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" Margin="0,0,10,0" />
</charting:Chart.Axes>
<charting:Chart.LegendStyle>
<Style TargetType="Control">
<Setter Property="Width" Value="0" />
<Setter Property="Height" Value="0" />
</Style>
</charting:Chart.LegendStyle>
<charting:Chart.Series>
<charting:ColumnSeries Name="LineSeriesBWSrc" ItemsSource="{Binding AlertPoints,UpdateSourceTrigger=PropertyChanged}"
IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" Title="Alerts" Background="Maroon" >
<charting:ColumnSeries.DataPointStyle>
<Style TargetType="charting:ColumnDataPoint">
<Setter Property="Background" Value="Crimson" />
</Style>
</charting:ColumnSeries.DataPointStyle>
</charting:ColumnSeries>
</charting:Chart.Series>
</charting:Chart>
Run Code Online (Sandbox Code Playgroud)
我已设法使用标记Y轴
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts" Margin="0,0,10,0" />
</charting:Chart.Axes>
Run Code Online (Sandbox Code Playgroud)
但是,如果我想标记X轴,它会出现在图表的顶部.我只是希望能够像"时间"和"事件"那样在轴上键入一些图例,但我找不到合适的方法来做到这一点.
如果我在X轴上执行相同操作,则图例和值将显示在图表的顶部.

当X轴的代码被引入时:
<charting:Chart.Axes>
<charting:LinearAxis Orientation="Y" Minimum="0" Title="Number of Alerts"
Run Code Online (Sandbox Code Playgroud)

好吧,我已经在这个问题上挣扎了相当长一段时间,并且阅读了一篇又一篇文章,试图了解这个问题。我正在尝试实施忙碌指示器,但只取得了部分成功。我有一个用 BusyIndicator 包装的 Shell 视图,如下所示:
<Window x:Class="Foundation.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Library.Controls.Views;assembly=Library"
xmlns:l="clr-namespace:Library.StaticClasses"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Name="ShellView"
Style="{StaticResource BusyWindowStyle}"
SourceInitialized="Window_SourceInitialized"
DataContext="{StaticResource ShellVM}">
<xctk:BusyIndicator x:Name="ShellBusyIndicator" IsBusy="{Binding IsBusy}" DisplayAfter="0">
<Grid>
<!--Content Here -->
</Grid>
</xctk:BusyIndicator>
Run Code Online (Sandbox Code Playgroud)
遵循 MVVM 模式,我有一个 ShellViewModel,如下所示:
public class ShellViewModel : ViewModelBase
{
#region constructor(s)
public ShellViewModel()
{
StateManager.IsBusyChange += new StateManager.IsBusyHandler(IsBusyEventAction);
}
#endregion constructor(s)
#region properties
private bool _IsBusy;
public bool IsBusy
{
get
{
return _IsBusy;
}
set
{
if (_IsBusy != value)
{
_IsBusy = value;
OnPropertyChanged("IsBusy");
}
}
}
private …Run Code Online (Sandbox Code Playgroud) 我下载了一个WPFToolkit源代码,因为我想覆盖DatePicker的默认通用模板.例如,我想覆盖此TextBox:
<primitives:DatePickerTextBox x:Name="PART_TextBox"
Grid.Row="0" Grid.Column="0"
Foreground="{TemplateBinding Foreground}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
Run Code Online (Sandbox Code Playgroud)
这意味着在我的项目中写这个:
<Style TargetType="{x:Type toolkit:DatePickerTextBox}">
<Setter Property="Text" Value="Bitte wählen" />
<Setter Property="MinHeight" Value="20" />
Run Code Online (Sandbox Code Playgroud)
工作得很好.但如果我想换VerticalContentAlignment="Stretch"到VerticalContentAlignment="Center"?? 默认样式始终覆盖它.谢谢你的回复!
我正在使用WPF工具包DataGrid.
如何获取所选行的单元格值?
嘿伙计们,首先我必须说,这可能看起来很多代码,但它很容易阅读.我试图绑定一些东西,我得到这个结果:
http://img694.imageshack.us/f/28475988.jpg/
正如您所看到的那样,数字,描述,行和列似乎是重复的.
在我的主表单设计师我有:
<Window x:Class="Visual_Command_Line.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Visual_Command_Line"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="Visual Command Line" MinHeight="750" MinWidth="900" Loaded="Window_Loaded" Icon="/Visual_Command_Line;component/Resources/icon16x16.ico" WindowStartupLocation="CenterScreen" WindowState="Maximized" Closing="Window_Closing">
<Window.Resources>
<local:ErrorListCollection x:Key="ErrorList" />
</Window.Resources>
<dg:DataGrid Name="DataGrid_ErrorList" IsReadOnly="True" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" CanUserSortColumns="False" ItemsSource="{Binding Source={StaticResource ErrorList}}">
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Binding="{Binding Path=GetNumber}" Header="" />
<dg:DataGridTextColumn Binding="{Binding Path=GetDescription}" Header="Description" Width="10*" />
<dg:DataGridTextColumn Binding="{Binding Path=GetLine}" Header="Line" Width="*" />
<dg:DataGridTextColumn Binding="{Binding Path=GetColumn}" Header="Column" Width="*" />
</dg:DataGrid.Columns>
</dg:DataGrid>
</Grid>
Run Code Online (Sandbox Code Playgroud)
当主表单加载我做:
((ErrorListCollection)this.FindResource("ErrorList")).RenewErrorList(((TabDocument)dockManager.ActiveDocument).currentAnalizedLine);
Run Code Online (Sandbox Code Playgroud)
这是ErrorListCollection类:
class ErrorListCollection : ObservableCollection<DebugError>
{
public ErrorListCollection()
{
}
public void RenewErrorList(AnalizedLine al) //also all …Run Code Online (Sandbox Code Playgroud) 我正在尝试将WPF工具包与我的Visual 2010项目一起使用(我对System.Windows.Controls.DataVisualization命名空间中的图表控件感兴趣),但无法确定要引用的程序集.
我已经安装了工具包,它似乎已安装到C:\Program Files (x86)\WPF Toolkit\v3.5.50211.1.我已经阅读了一些关于如何将程序集复制到GAC的帖子,但我尝试了以下代码:
import clr
clr.AddReference("WPFToolkit")
Run Code Online (Sandbox Code Playgroud)
仍然失败.
有人在VS2010最近使用过WPF Toolkit吗?你是如何添加引用的呢?
我想在WPF中使用timepicker控件.我在这里找到了一个实现.(http://wpftoolkit.codeplex.com/wikipage?title=TimePicker&referringTitle=Home).我安装了它.但无法理解如何使用它.我不知道我需要在XAML文件中写什么.
wpftoolkit ×10
wpf ×8
c# ×4
wpfdatagrid ×3
.net ×2
binding ×2
datagrid ×2
charts ×1
datepicker ×1
ironpython ×1
mvvm ×1
timepicker ×1
wpf-controls ×1
xaml ×1