wpfdatagrid

WPF DataGrid - highlight new rows when inserted into datagrid

浪尽此生 提交于 2019-12-05 07:54:31
I have a datagrid bound to an ObservableCollection, and what I'd like to do is highlight new rows when they are added to the datagrid (i.e. when a new object is inserted into the ObservableCollection). I'd like to highlight the rows when they are inserted by changing the background colour initially, but then having the colour fade back to normal over time. I've tried a variety of different methods to get it to work but nothing quite works properly. Method 1: I have an event trigger that fires when the column loads. It does fire when the element loads, but it seems to fire almost randomly on

how to change a row's style in WPF Datagrid?

孤街醉人 提交于 2019-12-05 02:51:58
问题 I am new to WPF, and need help in styling a specific row or rows in a datagrid in runtime, depending on some values of the stored data. I saw this thread but couldn't retrive my problem of row that exist only in runtime from columns that exist in design. any example will be gladly accepted. thanks! edited: I found this thread too, but I need a C# code... 回答1: I can't tell from your question whether you are adding columns to your grid at run time, but either way you can add a CellStyle to the

WPF. How to stop data trigger animation through binding?

帅比萌擦擦* 提交于 2019-12-05 01:41:03
In WPF toolkit datagrid I have a data trigger bound to opacity of cell element. When UpVisibility changes to 1 the path become visible and the animation starts to fade it to 0. Which works. However my problem now - if I need to prematurely stop/cancel the fading and am setting UpVisibility to 0 the Path is still visible and fading as nothing happened.... How to drop opacity to 0 instantly using MyValue object ? <Path Data="M 5,0 0,10 10,10" Height="10" Width="10" Fill="Green" Opacity="{Binding MyValue[0].UpVisibility}" Margin="5,0,5,0"> <Path.Style> <Style> <Style.Triggers> <DataTrigger

WPF DataGrid not updating on PropertyChanged

大城市里の小女人 提交于 2019-12-05 01:27:32
i've a problem updating my datagrid when clicking the button by using NotifyPropertyChanged. It works if i set the DataGrid.ItemsSource in code behind, but it doesn't if i set it in xaml. here's some code of code behind & xaml: namespace MyWpfDataBindingLab { public partial class NpcWindow : Window { DataCollection dc = new DataCollection(); public NpcWindow() { InitializeComponent(); //command binding code //... } private void Window_Loaded(object sender, RoutedEventArgs e) { //if i set the ItemsSource here, updating of the UI works //dataGrid1.ItemsSource = dc; } private void

WPF DataGrid GroupStyle

删除回忆录丶 提交于 2019-12-05 01:24:34
问题 I have the following DataGrid in WPF with two groups. First group is a bool flag which represents if a person is active/inactive. The second group (or sub-group) is the ID of each person. Each person can have multiple cities, therefore the grouping for the ID, because each person is shown multiple in the DataGrid . Here is the XAML: <DataGrid CanUserAddRows="False" AutoGenerateColumns="False" ItemsSource="{Binding DataSource}"> <DataGrid.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle>

WPF DataGrid AlternatingRowBackground and RowStyle precedence

為{幸葍}努か 提交于 2019-12-05 01:19:13
How do I make my RowStyle to get applied after AlternatingRowBackground ? I want items, having IsOrange as true to have Orange background regardless of alternating row background, which isn't the case currently. XAML: <DataGrid Name="g" AlternatingRowBackground="Blue" AlternationCount="2" ... SelectionMode="Single"> <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Style.Triggers> <DataTrigger Binding="{Binding IsOrange}" Value="Y"> <Setter Property="Background" Value="Orange" /> </DataTrigger> </Style.Triggers> </Style> </DataGrid.RowStyle> ... </DataGrid> LPL It's not a bug. In a Style

Prevent DataGrid Scrolling From Snapping To Rows

a 夏天 提交于 2019-12-05 00:49:17
问题 I have a DataGrid in which each row contains an ItemsControl. Because of this, the rows of the grid can be very tall. If a row is taller than the height of the grid, I'm unable to scroll to see the rest of the row because the DataGrid is automatically scrolling to the next row. That is, if I'm viewing the top half of row 1 and I click the vertical scrollbar's down arrow, it skips to the top of row 2. It doesn't let me see the bottom half of row 1. How do I make the DataGrid scroll over rows

WPF DataGridTextColumn multi-line input

倖福魔咒の 提交于 2019-12-05 00:11:28
I am using the WPF DataGrid control in .NET 4 that have a DataGridTextColumn. I want to be able to enter multi-line text. The line breaks are formatted correctly when I bind data to the column, but I've found no way of creating the line breaks when editing the text. <DataGrid ItemsSource="{Binding MyMessages}"> <DataGrid.Columns> <DataGridTextColumn Header="Message" Binding="{Binding Path=Message}" Width="Auto"/> <DataGrid.Columns> </DataGrid> Any suggestions? Try: <DataGridTextColumn Header="Message" Binding="{Binding Path=Message}" Width="Auto"> <DataGridTextColumn.ElementStyle> <Style

Creating an AttachedProperty to hold positions for scrollbar markers

五迷三道 提交于 2019-12-04 21:19:49
I have created slightly customized vertical scrollbar for my DataGrid. In it I have added an ItemsControl to hold positions of the selected items. Here is a mockup so far with hard-coded markers. Below is my customized vertical scrollbar template where the ItemsControl is placed with hard-coded marker values. <ControlTemplate x:Key="VertScrollBar" TargetType="{x:Type ScrollBar}"> <Grid> <Grid.RowDefinitions> <RowDefinition MaxHeight="18" /> <RowDefinition Height="0.00001*" /> <RowDefinition MaxHeight="18" /> </Grid.RowDefinitions> <Border Grid.RowSpan="3" CornerRadius="2" Background="#F0F0F0"

Styling the Xceed ColumnManagerCell

倖福魔咒の 提交于 2019-12-04 21:16:37
I'm interested in styling the column headers on an Xceed DataGrid. The goal is to make the background color grey, with a dark grey border around each header column cell. It seemed to me like the best way to do this was to style the ColumnManager: <Style TargetType="{x:Type xcdg:ColumnManagerCell}"> <Setter Property="Template" Value="{StaticResource ColumnManagerCellTemplate}"/> <Setter Property="BorderBrush" Value="#c5c5c5"/> <Setter Property="BorderThickness" Value="1,1,1,1"/> </Style> Using this template: <ControlTemplate x:Key="ColumnManagerCellTemplate" TargetType="xcdg:ColumnManagerCell">