datagrid

Bind DataGridColumns Header to DataContext of the window

本秂侑毒 提交于 2020-01-06 04:18:06
问题 I have a DataGrid and want to bind the Header -property to a property of my windows DataContext but I did not get it working. Binding can be such a pain as (for me) it is never clear which context this has when simply using Binding . I know that the "Context" in the Binding={} is a single element of the DataGrid s ItemsSource . But what is the "Context" for Header={Binding ???} ? I've already tried: Header="{Binding Path=DataContext.MyProperty, RelativeSource={RelativeSource Self}} Header="

Binding a DataGrid's CellTemplate content to an Element or a DependencyProperty defined on the templated CustomControl

微笑、不失礼 提交于 2020-01-06 04:08:06
问题 I'm using WPF's regular DataGrid inside a custom control. One of the DataGrid's cell template content should be bound to a the Text of a Textblock or to a DependencyProperty on the custom control. (If I could bind it to any of them it's good enough for me) I tried to do the following binding with the ElementName but it didn't work. I keep getting an DependencyProperty.UnsetValue - <DataGridTemplateColumn Header="Test"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ContentPresenter>

Binding a DataGrid's CellTemplate content to an Element or a DependencyProperty defined on the templated CustomControl

我是研究僧i 提交于 2020-01-06 04:07:29
问题 I'm using WPF's regular DataGrid inside a custom control. One of the DataGrid's cell template content should be bound to a the Text of a Textblock or to a DependencyProperty on the custom control. (If I could bind it to any of them it's good enough for me) I tried to do the following binding with the ElementName but it didn't work. I keep getting an DependencyProperty.UnsetValue - <DataGridTemplateColumn Header="Test"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ContentPresenter>

Persist sorting from DataGrid to ItemsSource collection

隐身守侯 提交于 2020-01-06 03:25:26
问题 I have a DataGrid and I'm trying to do the Sort thing the most straightforward way: by clicking on the header of each column. This is working great on the View ( in the MVVM context ), but I want to sort the underlying ViewModel collection ( ObservableCollection ) too. Any suggestions on how to implement the source collection? 回答1: Bind the grid to a ListCollectionView , initialised with the ObservableCollection . The grid will use your pre-created ICollectionView instead of creating it's own

DataGrid TemplateColumn - Triger an event when changes occured(asp:radiobuttonlist)

本秂侑毒 提交于 2020-01-06 03:21:05
问题 To get the row index of DataGrid when change(asp:radiobuttonlist) occur in row of the TemplateColumn <asp:DataGrid ID="dgTier2" runat="server" AutoGenerateColumns="False" Width="578px" Height="83px" OnItemDataBound="dgTier2_ItemDataBound"> <asp:BoundColumn DataField="TypeID" HeaderText="TypeID"> </asp:BoundColumn> <asp:BoundColumn DataField="Type" HeaderText="Category Type"> </asp:BoundColumn> <asp:TemplateColumn HeaderText="Manual Tracking Option" > <ItemStyle VerticalAlign="Bottom" />

WPF how to display text on progress bar

谁都会走 提交于 2020-01-06 02:35:47
问题 I have a DataGrid, one column is designed to display download percent. Below is my code: <DataGridTemplateColumn Header="Percent" IsReadOnly="True" Width="*"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <DockPanel> <Button Margin="5,0,0,0" DockPanel.Dock="Right" VerticalContentAlignment="Center" Style="{StaticResource BasicButtonStyle}" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.StopButtonClickCommand}" >

How do I bind selectedItem property of WPFToolkit-Datagrid to my viewmodel property?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 02:23:45
问题 I have a WPFToolkit-datagrid and a View-model class with a property - "SelectedGridItems" How do I bind selectedItem property of WPFToolkit-Datagrid to my viewmodel property ("SelectedGridItems") ? 回答1: Here is an attached property that hooks to the SelectionChanged event of the ListBox and populates a list of selected items to the ViewModel. You can simply change "ListBox" to "DataGrid". http://marlongrech.wordpress.com/2009/06/02/sync-multi-select-listbox-with-viewmodel/ Edit: Adding source

How do I bind selectedItem property of WPFToolkit-Datagrid to my viewmodel property?

╄→尐↘猪︶ㄣ 提交于 2020-01-06 02:23:27
问题 I have a WPFToolkit-datagrid and a View-model class with a property - "SelectedGridItems" How do I bind selectedItem property of WPFToolkit-Datagrid to my viewmodel property ("SelectedGridItems") ? 回答1: Here is an attached property that hooks to the SelectionChanged event of the ListBox and populates a list of selected items to the ViewModel. You can simply change "ListBox" to "DataGrid". http://marlongrech.wordpress.com/2009/06/02/sync-multi-select-listbox-with-viewmodel/ Edit: Adding source

How to change background of DataGridCell when IsEditing=True in WPF

非 Y 不嫁゛ 提交于 2020-01-05 18:56:26
问题 Setting background works fine for DataGridCheckBoxColumn but not for DataGridTextColumn . I set it for cell in resources: <Style TargetType="{x:Type DataGridCell}"> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="Background" Value="#ffff00" /> </Trigger> <Trigger Property="IsEditing" Value="True"> <Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderBrush" Value="#00ff00" /> <Setter Property="Background" Value="#00ff00" /> </Trigger> </Style

Datagrid custom header

瘦欲@ 提交于 2020-01-05 09:03:10
问题 I want to add an extra row to Datagrid's header row that will contain textboxes (for searching). This row should appear directly under the original header and look like regular item header. This is my code so far: <Window.Resources> <Style x:Key="DataGridColumnHeaderStyle1" TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridColumnHeader}"> <Grid VerticalAlignment="Center" HorizontalAlignment="Stretch"> <Grid