Search Results

Search found 86 results on 4 pages for 'datagridtemplatecolumn'.

Page 1/4 | 1 2 3 4  | Next Page >

  • wpftoolkit DataGridTemplateColumn Template binding

    - by Guillaume
    I want my datagrid columns to share a cell/celledit template. I have the solution do that (thanks to WPF DataGridTemplateColumn shared template?). Now what I would love to is improving the readability by avoiding all the node nesting. My current view looks like that: <wpftk:DataGrid ItemsSource="{Binding Tests}" AutoGenerateColumns="False"> <wpftk:DataGrid.Resources> <DataTemplate x:Key="CustomCellTemplate"> <TextBlock Text="{TemplateBinding Content}"/> </DataTemplate> <DataTemplate x:Key="CustomCellEditingTemplate"> <TextBox Text="{TemplateBinding Content}"></TextBox> </DataTemplate> </wpftk:DataGrid.Resources> <wpftk:DataGrid.Columns> <wpftk:DataGridTemplateColumn Header="Start Date"> <wpftk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <ContentPresenter ContentTemplate="{StaticResource CustomCellTemplate}" Content="{Binding StartDate}"/> </DataTemplate> </wpftk:DataGridTemplateColumn.CellTemplate> <wpftk:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <ContentPresenter ContentTemplate="{StaticResource CustomCellEditingTemplate}" Content="{Binding StartDate}"/> </DataTemplate> </wpftk:DataGridTemplateColumn.CellEditingTemplate> </wpftk:DataGridTemplateColumn> <!--and again the whole block above for each columns...--> </wpftk:DataGrid.Columns> </wpftk:DataGrid> What I would like to achieve is to bind the value at the DataGridTemplateColumn level and propagate it to the template level. Anyone know how to do that? What I tried to do is something like that: <wpftk:DataGrid ItemsSource="{Binding Tests}" AutoGenerateColumns="False"> <wpftk:DataGrid.Resources> <DataTemplate x:Key="CustomCellTemplate"> <TextBlock Text="{Binding}"/> </DataTemplate> <DataTemplate x:Key="CustomCellEditingTemplate"> <TextBox Text="{Binding}"></TextBox> </DataTemplate> </wpftk:DataGrid.Resources> <wpftk:DataGrid.Columns> <wpftk:DataGridTemplateColumn Header="Start Date" Binding="{Binding StartDate}" CellTemplate="{StaticResource CustomCellTemplate}" CellEditingTemplate="{StaticResource CustomCellEditingTemplate}"/> <wpftk:DataGridTemplateColumn Header="End Date" Binding="{Binding EndDate}" CellTemplate="{StaticResource CustomCellTemplate}" CellEditingTemplate="{StaticResource CustomCellEditingTemplate}"/> </wpftk:DataGrid.Columns> </wpftk:DataGrid> Obviously the binding porperty is not a valid property of the DataGridTemplateColumn but maybe by playing with the datacontext and some relative source could do the trick but frankly I can't find a way to implement that. Not sure if what I want is possible and i'm willing to accept a "no way you can do that" as an answer NOTE: The TextBlock/TextBox in the template is just for test (the real template is much more complex) DataGridTextColumn will not do the trick Thanks in advance

    Read the article

  • Styling columns based on DataGridTemplateColumn in a WPF DataGrid

    - by nareshbhatia
    I am using a WPF DataGrid where one of the columns has a requirement to show an "Edit" hyperlink if the row is editable - this is indicated by a boolean flag in the backing model for the row. I was able to achieve this using a DataGridTemplateColumn - no problems. However an additional requirement on the entire row is not to show any highlights when the row is selected (this is a blue background by default). I have been able to achieve this on other columns by defining the DataGridCell style with a transparent background, e.g. <DataGridTextColumn Header="Id" Binding="{Binding Path=Id}" HeaderStyle="{StaticResource DataGridColumnHeaderStyle}" CellStyle="{StaticResource DataGridCellStyle}" /> where DataGridCellStyle is defined as follows: <Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}"> <Setter Property="Background" Value="Transparent" /> ... </Style> However the column in question, a DataGridTemplateColumn, does not offer a "CellStyle" attribute which I can use for turning off selection highlights. So my question is how to set the cell style when using a DataGridTemplateColumn? Here's my implementation of the column which satisfies the first requirement (i.e. showing an "Edit" hyperlink if the row is editable): <DataGridTemplateColumn Header="Actions" HeaderStyle="{StaticResource CenterAlignedColumnHeaderStyle}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Visibility="{Binding Path=Editable, Converter={StaticResource convVisibility}}" Style="{StaticResource CenterAlignedElementStyle}"> <Hyperlink Command="..." CommandParameter="{Binding}"> <TextBlock Text="Edit" /> </Hyperlink> </TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> Thanks.

    Read the article

  • DataGridTemplateColumn for individual control-column vs DataGridTextColumn

    - by msfanboy
    Hello, what is the difference, both works: DataGridTemplateColumn versus DataGridTextColumn <DataGridTemplateColumn Header="Homework"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <RichTextBox > <FlowDocument> <Paragraph> <Run Text="{Binding Homework}"/> </Paragraph> </FlowDocument> </RichTextBox> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTextColumn Header="Homework"> <DataGridTextColumn.CellTemplate> <DataTemplate> <RichTextBox > <FlowDocument> <Paragraph> <Run Text="{Binding Homework}"/> </Paragraph> </FlowDocument> </RichTextBox> </DataTemplate> </DataGridTextColumn.CellTemplate> </DataGridTextColumn >

    Read the article

  • Apply Storyboard Animation to DataGridTemplateColumn depending on Binding value change

    - by Neo
    I have a DataGridTemplateColumn on a WPF DataGrid which has a binding to a double type. I wish to apply a Storyboard Animation when the value goes down and another Storyboard Animation when the value goes up. I've got the following code to start with: <dg:DataGridTemplateColumn Header="My Double"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=MyDouble, NotifyOnTargetUpdated=True}" TargetUpdated="dgRates_TargetUpdated"> <TextBlock.Triggers> <EventTrigger RoutedEvent="Binding.TargetUpdated"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:2" From="1.0" To="0.0" /> </Storyboard> </BeginStoryboard> </EventTrigger> </TextBlock.Triggers> </TextBlock> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> How can I achieve this? Thanks.

    Read the article

  • WPF DataGrid using a DataGridTemplateColumn rather than a DataGridComboBoxColumn to show selected value at load

    - by T
    My problem was that using a DataGridComboBoxColumn I couldn’t get it to show the selected value when the DataGrid loaded.  Instead, the user would have to click in the cells and like magic, the current selected values would appear and it looked the way I wanted it to on load. Here is what I had <DataGridComboBoxColumn MinWidth="150" x:Name="crewColumn" Header="Crew" ItemsSource="{Binding JobEdit.Crews, Source={StaticResource Locator}}" DisplayMemberPath="Name" SelectedItemBinding="{Binding JobEdit.SelectedCrew, Mode=TwoWay, Source={StaticResource Locator}}" />   Here is what I changed it too.  This works great.  It displays the selected item when the DataGrid loads and shows the combo box when the user goes into edit mode.   <DataGridTemplateColumn Header="Crew" MinWidth="150"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Crew.Name}"></TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding JobEdit.Crews, Source={StaticResource Locator}}" DisplayMemberPath="Name" SelectedItem="{Binding JobEdit.SelectedCrew, Mode=TwoWay, Source={StaticResource Locator}}"></ComboBox> </DataTemplate> </DataGridTemplateColumn.CellEditingTemplate> </DataGridTemplateColumn>

    Read the article

  • How can I center a Silverlight DataGridTemplateColumn header?

    - by Mike Pateras
    I want to center the header on a Silverlight DataGridTemplateColumn. The following code gets me most of the way there: DataGridTemplateColumn column = new DataGridTemplateColumn(); column.CellTemplate = Resources[templateName] as DataTemplate; column.Header = headerName; column.HeaderStyle = new Style { TargetType = typeof(DataGridColumnHeader) }; column.HeaderStyle.Setters.Add(new Setter(DataGridColumnHeader.HorizontalAlignmentProperty, HorizontalAlignment.Center)); The header is, indeed, centered, but if the column is expanded, the header doesn't stretch. It just remains it's original width, leaving white gaps on either side of it, which looks terrible. What is the proper way to center the column header, such that it still occupies the full width?

    Read the article

  • custom control in DataGridTemplateColumn

    - by Johnsonlu
    Hi all, I'd like to add my custom control into a template column of data grid. The custom control is very similar to a text box, but has an icon in it. The user can click the icon, and selects an item from a prompted window, then the selected item will be filled into the text box. My problem is when the text box is filled, after I click the second column, the text will disappear. If I replace the custom control with a simple text box, the result is the same. Here is the sample code: //Employee.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SimpleGridTest { public class Employee { public string Department { get; set; } public int ID { get; set; } public string Name { get; set; } } } Mainwindow.xaml <Window x:Class="SimpleGridTest.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"> <Grid> <DataGrid x:Name="grid" Grid.Row="1" Margin="5" AutoGenerateColumns="False" RowHeight="25" RowHeaderWidth="10" ItemsSource="{Binding}" CanUserAddRows="True" CanUserSortColumns="False"> <DataGrid.Columns> <DataGridTemplateColumn Header="Department" Width="150"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding Department}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTextColumn Header="ID" Binding="{Binding Path=ID}" Width="100"/> <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="200"/> </DataGrid.Columns> </DataGrid> </Grid> </Window> MainWindow.xaml.cs using System.Windows; using System.Collections.ObjectModel; namespace SimpleGridTest { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private ObservableCollection<Employee> _employees = new ObservableCollection<Employee>(); public ObservableCollection<Employee> Employees { get { return _employees; } set { _employees = value; } } public MainWindow() { InitializeComponent(); grid.ItemsSource = Employees; } } } How can I fix this problem? Or I need to write a DataGrid***Column as DataGridTextColumn? Thanks in advance! Best Regards, Johnson

    Read the article

  • WPF - How to bind a DataGridTemplateColumn

    - by Andy T
    Hi, I am trying to get the name of the property associated with a particular DataGridColumn, so that I can then do some stuff based on that. This function is called when the user clicks context menu item on the column's header... This is fine for the out-of-the-box ready-rolled column types like DataGridTextColumn, since they are bound, but the problem is that some of my columns are DataGridTemplateColumns, which are not bound. private void GroupByField_Click (object sender, RoutedEventArgs e){ MenuItem mi = (MenuItem)sender; ContextMenu cm = (ContextMenu) mi.Parent; DataGridColumnHeader dgch = (DataGridColumnHeader) cm.PlacementTarget; DataGridBoundColumn dgbc = (DataGridBoundColumn) dgch.Column; Binding binding = (Binding) dgbc.Binding; string BoundPropName = binding.Path.Path; //Do stuff based on bound property name here... } So, take for example my 'Name' column... it's a DataGridTemplateColumn (since it has an image and some other stuff in there). Therefore, it is not actually bound to the 'Name' property... but I would like to be, so that the above code will work. My question is two-part, really: 1) Is it possible to make a DataGridTemplateColumn be BOUND, so that the above code would work? Can I bind it somehow to a property? 2) Or do I need to something entirely different, and change the code above? Thanks in advance! AT

    Read the article

  • WPF Datagrid -DataGridTemplateColumn tab focus issue

    I am using Microsoft WPF datagrid. I have noticed a strange behavior with WPF datagrid DataGridTemplateColumn. When you use the templateColumn in the grid and the template column contains some controls when you tab from the previous column the focus is not automatically given to the first element declared in the template column. The foucs is initally set on the border of the template column and when we tab of once agin the focus goes to the first column. Any workaround for this issue. How can i set the focus to go the first element in the template column of the datagrid when i tab off.

    Read the article

  • DataGrid: dynamic DataTemplate for dynamic DataGridTemplateColumn

    - by Lukas Cenovsky
    I want to show data in a datagrid where the data is a collection of public class Thing { public string Foo { get; set; } public string Bar { get; set; } public List<Candidate> Candidates { get; set; } } public class Candidate { public string FirstName { get; set; } public string LastName { get; set; } ... } where the number of candidates in Candidates list varies at runtime. Desired grid layout looks like this Foo | Bar | Candidate 1 | Candidate 2 | ... | Candidate N I'd like to have a DataTemplate for each Candidate as I plan changing it during runtime - user can choose what info about candidate is displayed in different columns (candidate is just an example, I have different object). That means I also want to change the column templates in runtime although this can be achieved by one big template and collapsing its parts. I know about two ways how to achieve my goals (both quite similar): Use AutoGeneratingColumn event and create Candidates columns Add Columns manually In both cases I need to load the DataTemplate from string with XamlReader. Before that I have to edit the string to change the binding to wanted Candidate. Is there a better way how to create a DataGrid with unknown number of DataGridTemplateColumn? Note: This question is based on dynamic datatemplate with valueconverter

    Read the article

  • How can I sort a DataGridTemplateColumn on a WPF Toolkit DataGrid?

    - by Kilhoffer
    I have a WPF Toolkit DataGrid with one DataGridTemplateColumn. I've specified in a grid attribute that I wish all columns to be sortable, but the DataGridTemplateColumn won't allow it. All other columns do allow sorting. I've even tried explicitly setting CanUserSort to true for that column, but no luck. Is it even possible to sort a template column? I've provided a custom sorter that works for all columns, but the header won't allow a sort click. <Controls:DataGrid ItemsSource="{Binding Events}" AutoGenerateColumns="False" CanUserSortColumns="True" CanUserReorderColumns="False" Sorting="DataGrid_Sorting" x:Name="EventsGrid"> <Controls:DataGrid.Columns> <Controls:DataGridTemplateColumn Header="Type" Width="42" CanUserResize="False"> <Controls:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Image Source="{Binding EventTypeImage, Mode=OneWay}" HorizontalAlignment="Center" Width="16"/> </DataTemplate> </Controls:DataGridTemplateColumn.CellTemplate> </Controls:DataGridTemplateColumn> <Controls:DataGridTextColumn Header="Source" Binding="{Binding Source, Mode=OneWay}" /> <Controls:DataGridTextColumn Header="Details" MinWidth="175" Binding="{Binding Details, Mode=OneWay}" /> <Controls:DataGridTextColumn Header="Timestamp" MinWidth="175" Binding="{Binding Timestamp, Mode=OneWay}" IsReadOnly="True"/> </Controls:DataGrid.Columns> </Controls:DataGrid>

    Read the article

  • Get textbox binding in wpf datagridtemplatecolumn

    - by klawusel
    Hi I have a wpf datagrid containing multiple datagridtemplatecolumns, which all are build up from a datatemplate which contains a textbox. Now I want to get the binding of the textbox (I have a reference to the template column which textbox's binding I woukld like to determine). Alternatively it would be nice to return the X:Name of the template column Any hints? Regards klaus

    Read the article

  • Generic styles for DataGridTemplateColumn Headers & Cells

    - by user557765
    I am struggling to define templates for my DataGrid columns. Here is the code that I have working at the moment: <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" > <t:DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldNameVertical}" Text="Date" /> </DataTemplate> </t:DataGridTemplateColumn.HeaderTemplate> <t:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" /> </DataTemplate> </t:DataGridTemplateColumn.CellTemplate> </t:DataGridTemplateColumn> .. .. .. </t:DataGrid.Columns> I would like to define HeaderTemplate & CellTemplate as reusable styles -- so that each column would be as brief as something like this: <t:DataGrid.Resources> <DataTemplate x:Key="dgHeaderStyle"> <TextBlock Style="{StaticResource FieldNameVertical}" Text="{Binding}" /> </DataTemplate> <DataTemplate x:Key="dgCellStyle"> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding}" /> </DataTemplate> </t:DataGrid.Resources> <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" Header="Date" Binding="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> <t:DataGridTemplateColumn Width="100" Header="Dealer" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> ... </t:DataGrid.Columns> Every attempt I make has failed. I had hoped to implement something like the "solution" snippet in the initial entry of WPF DataGrid HeaderTemplate Mysterious Padding. However, I can't seem to adapt it to what I'm doing.

    Read the article

  • how to format the data inside the DataGridTemplateColumn in datagrid

    - by prince23
    hi, this is my xaml code where i have 2 fields placed under one template column. now i am getting the format the output like this so that i can specify the space betweeen these 2 columns Color red image1 green image2 green image2 white image6 so that output looks good. How can i define space between them so that it looks like the above one right now thw output is like this color Redimage1 greenimage2 greenimage2 whiteimage6 <sdk:DataGridTemplateColumn Header="Color" Width="80"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Loaded ="StackPanel_Loaded" Orientation="Horizontal" Background="Transparent"> <TextBlock Text="{Binding Color}" TextWrapping="NoWrap" HorizontalAlignment="Center" Foreground="Blue"></TextBlock> <Image x:Name="imgTargetScore" Source ="{Binding ColorImage}" Width="20" Height="20" Stretch ="Fill"/> </StackPanel> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> loking forward for an solution thanks in advance prince

    Read the article

  • wpf DataGrid.datagridtemplatecolumn combobox does not update itemssource

    - by David
    <Grid Loaded="Grid_Loaded"> <DataGrid Margin="10,10,10,162" x:Name="dataGrid1" ItemsSource="{Binding myItemsSource}"/> <DataGrid Margin="10,164,10,10" x:Name="dataGrid2" ItemsSource="{Binding myItemsSource}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="A" Binding="{Binding A}"></DataGridTextColumn> <DataGridComboBoxColumn Header="B" TextBinding="{Binding B}" x:Name="columnB"></DataGridComboBoxColumn> <DataGridTemplateColumn Header="C" x:Name="columnC"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox Text="{Binding C, Mode=TwoWay}" SelectedItem="{Binding C, Mode=TwoWay}"> <ComboBoxItem Content="AAA"/> <ComboBoxItem Content="BBB"/> <ComboBoxItem Content="CCC"/> <ComboBoxItem Content="XXX"/> <ComboBoxItem Content="YYY"/> <ComboBoxItem Content="ZZZ"/> </ComboBox> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid> columnB (buidin DataGridComboBoxColumn) is working. columnB.ItemsSource = LstForCbx; public List LstForCbx = new List{"AAA", "BBB", "CCC", "XXX", "YYY", "ZZZ"}; columnC combobox in DataGridComboBoxColumn not working. What wrong with my code?

    Read the article

  • events not getting fired properly

    - by prince23
    hi, this is my xaml code. datagrid within another data grid. <sdk:DataGrid x:Name="dgLevel1" AutoGenerateColumns="False" VerticalAlignment="Top" IsReadOnly="True" Margin="12,12,0,0" RowDetailsVisibilityChanged="dgLevel1_RowDetailsVisibilityChanged" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected" Height="412" HorizontalAlignment="Left" Width="816"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Width="24" Height="24" Click="ExpandLevel1_Click"> <Image x:Name="imgLevel1" Source="Images/detail.JPG" Stretch="None"/> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Actual" Visibility="Collapsed"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding UniqueName}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="550" /> <!--<sdk:DataGridTextColumn Binding="{Binding UniqueName}" Visibility="Collapsed"/>--> <sdk:DataGridTemplateColumn Header="Actual" Width="80" > <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding Age}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> <sdk:DataGrid.RowDetailsTemplate> <DataTemplate> <StackPanel Width="805"> <sdk:DataGrid x:Name="dgLevel2" Width="797" Margin="17,0,0,0" HeadersVisibility ="None" AutoGenerateColumns="False" HorizontalAlignment="Center" IsReadOnly="True" RowDetailsVisibilityChanged="dgLevel2_RowDetailsVisibilityChanged" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Width="24" Height="30" Click="ExpandLevel2_Click"> <Image x:Name="imgLevel2" Source="Images/detail.JPG" Stretch="None"/> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTextColumn Binding="{Binding School}" Width="528" /> <sdk:DataGridTextColumn Binding="{Binding College}" Visibility="Collapsed" /> <sdk:DataGridTemplateColumn Header="Actual" Width="80"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding DOB}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid> </StackPanel> </DataTemplate> </sdk:DataGrid.RowDetailsTemplate> </sdk:DataGrid> i have 2 data grid and have 2 image buttons in both the grid . but the event which is in datagrid ExpandLevel1 _Click and ExpandLevel2 _Click is not getting fired properly. some times get fired some times no when i click the button first this event gets fired then ExpandLevel1_Click then **dgLevel1_RowDetailsVisibilityChanged . same thing is happening for the datagrid 2 ExpandLevel2_Click then dgLevel2_RowDetailsVisibilityChanged** there are scenario where first datagrid event gets fired first then button click events why is this happening .is there any solution for this looking forward an solutions thanks in advance. prince

    Read the article

  • is there any way we can disable on mouse over event on certain columns of an data grid

    - by prince23
    hi, here wat i am trying to do is that on mouse over of first column i need to hit mouse MouseEnter event and show the pop up which i have kept there rest all other column i dnt need to to show the pop up so i am having this fuction there MouseLeave="Row_MouseLeave" <sdk:DataGrid MinHeight="100" x:Name="dgCounty" AutoGenerateColumns="False" VerticalAlignment="Top" Grid.Row="1" IsReadOnly="True" Margin="5,5,5,0" RowDetailsVisibilityChanged="dgCounty_RowDetailsVisibilityChanged" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected" MouseEnter="dgCounty_MouseEnter" MouseLeave="dgCounty_MouseLeave" SelectionChanged="dgCounty_SelectionChanged" LoadingRow="dgCounty_LoadingRow1" UnloadingRow="dgCounty_UnloadingRow"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Width="24" Height="24" Click="Details_Click"> <Image x:Name="img" Source="Images/detail.JPG" Stretch="None"/> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="ID"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeID}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Name"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeFName}" MouseLeave="Row_MouseLeave" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="MailID"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeMailID}" MouseLeave="Row_MouseLeave" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid> in code behind void Row_MouseLeave(object sender, MouseEventArgs e) { Show.Visibility = Visibility.Collapsed; PoPGrid.Visibility = Visibility.Collapsed; } void Row_MouseEnter(object sender, MouseEventArgs e) { } the pop up her is like the ajax modal pop up wat we do in asp.net i am able to show data in pop up now the main issue is i need to show pop up only on the 2 column. rest all other column i need to hide the pop up when i move mouse over on that column. i am trying this concept it is not working is there any way i can achive it as i said only need to show pop up on mouse over of the 2 column thanks in advance prince

    Read the article

  • why is that we always get an extra column show in datagrid

    - by prince23
    hi, i have four columns specfied but why is that i always see one extra column shown in the output this is my xaml code <Grid x:Name="LayoutRoot" Background="White" Height="492" Width="453"> <sdk:DataGrid MinHeight="100" x:Name="dgCounty" AutoGenerateColumns="False" VerticalAlignment="Top" Grid.Row="1" IsReadOnly="True" Margin="5,5,5,0" RowDetailsVisibilityChanged="dgCounty_RowDetailsVisibilityChanged" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected"> <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Width="24" Height="24" Click="Details_Click"> <Image x:Name="img" Source="Images/detail.JPG" Stretch="None"/> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="ID"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeID}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Name"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeFName}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="MailID"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding EmployeeMailID}" /> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid> is there any setting that we need to do to remove that extra column? thanks in advance for the help.

    Read the article

  • WPF DataGridTemplateColumn. Am I missing something?

    - by plotnick
    <data:DataGridTemplateColumn Header="Name"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Name}"> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> <data:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <TextBox Text="{Binding Name}"> </DataTemplate> </data:DataGridTemplateColumn.CellEditingTemplate> </data:DataGridTemplateColumn> It's clear example of Template column, right? What could be wrong with that? So, here is the thing - when a user navigates through DataGrid with hitting TAB-key, it needs to hit the TAB twice(!) to be able to edit text in TextBox. How could I make it editable as soon as the user gets the column focus, I mean even if he just starts typing? Ok. I found a way - into Grid.KeyUp() I put the code below: if (Grid.CurrentColumn.Header.ToString() == "UserName") { if (e.Key != Key.Escape) { Grid.BeginEdit(); // Simply send another TAB press if (Keyboard.FocusedElement is Microsoft.Windows.Controls.DataGridCell) { var keyEvt = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab) { RoutedEvent = Keyboard.KeyDownEvent }; InputManager.Current.ProcessInput(keyEvt); } } }

    Read the article

  • Set binding for DataTemplate components in code

    - by Chouppy
    Hi; sorry if I'm not clear, it's not really clear in my head too (especially after trying to find my way in other posts :p) What I'm willing to do is creating DataGrids in code, with zero to numerous columns containing a button, which will call one same function but with a "parameter" (different for each column). Here is what I got so far : DataGrid created in code DataTemplate defined in the xaml resources (with a button) DataGridTemplateColumn which uses the above DataTemplate Is it possible to bind the button's properties (in the DataTemplate), to the DataGridTemplateColumn properties (in my case, the column header would be ok), and how? Is there a way to get an access to the DataTemplate components (the button for example) in code, and modify their properties? Is it possible (and not hazardous) to create a DataTemplate in code? I declared mine in xaml because I found a post advising to do so instead of code. Thanks for your help.

    Read the article

  • How to customize and reuse a DataGridColumnHeader style?

    - by instcode
    Hi all, I'm trying to customize the column headers of a DataGrid to show sub-column headers as in the following screenshot: I've made a style for 2 sub-column as in the following XAML: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data" xmlns:sl="clr-namespace:UI" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="UI.ColumnHeaderGrid" mc:Ignorable="d"> <UserControl.Resources> <Style x:Key="SplitColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader"> <Setter Property="Foreground" Value="#FF000000"/> <Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="IsTabStop" Value="False"/> <Setter Property="SeparatorBrush" Value="#FFC9CACA"/> <Setter Property="Padding" Value="4"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="primitives:DataGridColumnHeader"> <Grid x:Name="Root"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Rectangle x:Name="BackgroundRectangle" Fill="#FF1F3B53" Stretch="Fill" Grid.ColumnSpan="2"/> <Rectangle x:Name="BackgroundGradient" Stretch="Fill" Grid.ColumnSpan="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0"> <GradientStop Color="#FCFFFFFF" Offset="0.015"/> <GradientStop Color="#F7FFFFFF" Offset="0.375"/> <GradientStop Color="#E5FFFFFF" Offset="0.6"/> <GradientStop Color="#D1FFFFFF" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition Width="1"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Grid.ColumnSpan="3" Text="Headers" TextAlignment="Center"/> <Rectangle Grid.Row="1" Grid.ColumnSpan="3" Fill="{TemplateBinding SeparatorBrush}" Height="1"/> <TextBlock Grid.Row="2" Grid.Column="0" Text="Header 1" TextAlignment="Center"/> <Rectangle Grid.Row="2" Grid.Column="1" Fill="{TemplateBinding SeparatorBrush}" Width="1"/> <TextBlock Grid.Row="2" Grid.Column="2" Text="Header 2" TextAlignment="Center"/> <Path x:Name="SortIcon" Grid.Column="2" Fill="#FF444444" Stretch="Uniform" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Width="8" Opacity="0" RenderTransformOrigin=".5,.5" Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z "/> </Grid> <Rectangle x:Name="VerticalSeparator" Fill="{TemplateBinding SeparatorBrush}" VerticalAlignment="Stretch" Width="1" Visibility="{TemplateBinding SeparatorVisibility}" Grid.Column="1"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <data:DataGrid x:Name="LayoutRoot"> <data:DataGrid.Columns> <data:DataGridTemplateColumn HeaderStyle="{StaticResource SplitColumnHeaderStyle}"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Border Grid.Column="0" BorderBrush="#FFC9CACA" BorderThickness="0,0,0,0"> <TextBlock Grid.Column="0" Text="{Binding GridData.Column1}"/> </Border> <Border Grid.Column="1" BorderBrush="#FFC9CACA" BorderThickness="1,0,0,0"> <TextBlock Grid.Column="0" Text="{Binding GridData.Column2}"/> </Border> </Grid> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid> Now I want to reuse & extend this style to support 2-6 sub-column headers but I don't know if there is a way to do this, like ContentPresenter "overriding": <Style x:Key="SplitColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader"> <Setter property="Template"> <Setter.Value> ... <ContentPresenter Content="{TemplateBinding Content}".../> ... </Setter.Value> </Setter> </Style> <Style x:Key="TwoSubColumnHeaderStyle" BasedOn="SplitColumnHeaderStyle"> <Setter property="Content"> <Setter.Value> <Grid 2x2.../> </Setter.Value> </Setter> </Style> <Style x:Key="ThreeSubColumnHeaderStyle" BasedOn="SplitColumnHeaderStyle"> <Setter property="Content"> <Setter.Value> <Grid 2x3.../> </Setter.Value> </Setter> </Style> Anyway, please help me on these issues: Given the template above, how to support more sub-column headers without having to create new new new new template for each? Assume that the issue above is solved. How could I attach column names outside the styles? I see that some parts, properties & visualization rules in the XAML are just copies from the original Silverlight component's style, i.e. BackgroundGradient, BackgroundRectangle, VisualStateManager... They must be there in order to support default behaviors or effects but... does anyone know how to remove them, but keep all the default behaviors/effects? Please be specific because I'm just getting start with C# & Silverlight. Thanks.

    Read the article

  • how to bind the image dynamically for datagrid in.cs

    - by prince23
    hi, this is my xaml code. <sdk:DataGrid x:Name="dgMarks" CanUserResizeColumns="False" SelectionMode="Single" AutoGenerateColumns="False" VerticalAlignment="Top" IsReadOnly="True" Margin="13,44,0,0" RowDetailsVisibilityChanged="dgMarks_RowDetailsVisibilityChanged" RowDetailsVisibilityMode="Collapsed" Height="391" HorizontalAlignment="Left" Width="965" SelectionChanged="dgMarks_SelectionChanged" VerticalScrollBarVisibility="Visible" > <sdk:DataGrid.Columns> <sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="myButton" Click="ExpandMarks_Click"> <TextBlock Text="{Binding Level}" TextWrapping="NoWrap" ></TextBlock> <Image x:Name="imgMarks" Stretch="None"/> </Button> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Name" Visibility="Collapsed"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate > <sdk:Label Content="{Binding Name}"/> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> <sdk:DataGridTemplateColumn Header="Marks" Width="80"> <sdk:DataGridTemplateColumn.CellTemplate> <DataTemplate> <sdk:Label Content="{Binding Marks}"/> </DataTemplate> </sdk:DataGridTemplateColumn.CellTemplate> </sdk:DataGridTemplateColumn> </sdk:DataGrid.Columns> </sdk:DataGrid> from database i am getting these values name marks Level abc 23 0 xyz 67 1 yu 56 0 aa 89 1 here i am binding these values for datagrid. i have an tricky thing to be done .based on the level i should be binding image if level value is 1 then bind the image. if level value is 0 then do not bind the image for that row i know this is how we need to handle but where should i write this code in which events? Image imgLevel = (Image)templateTrendScore.FindName("imgMarks"); if (level1==1) { imgLevel .Source = new BitmapImage(new Uri("/Images/image1.JPG", UriKind.Relative)); } any help would be great thanks in advance

    Read the article

  • Dynamic DataGrid columns in WPF DataGrid based on the underlying set of data (and their type)

    - by StatsMan
    Hello everyone, I've got kind of a conceptual question. I am in the process of wrapping some statistics classes I wrote into WPF. For that I have two DataGrid(-Views, currently in WinForms). In one DataGrid each row represents a column in the other. There I can set-up different variables (as in mathematical/statistical variables) with fields like "Header", "DataType", "ValidationBehaviour", "DisplayType". There I can also set-up how it should be displayed. Some Columns can automatically be set to ComboBoxColumns, some TextBoxColumns, and so on and so forth. So, now once I've set-up these Columns I can go to the other grid and enter my data. I may, for instance, have generated (in grid 1) one Column called "Annual Gross Salary" with input of numerical values. Another Column called "Education" with "0=NoEducation", "1=College Level", "3=Universitary" etc. These labels are displayed as text in the combobox and my statistics engine behind then selects the respective value (0-3) for calculations (i.e. ordinal, nominal variables). Sooo. In WinForms I could basically generate all the columns by hand in code and then add my data in the respective cells/rows. Now in WPF I thought that must be easy to realise. However, yesterday I got started with ICustomPropertyDescriptor which (maybe I was too thick) didn't give me the results I was looking for. Basically, I just need to be able to dynamically generate columns (and rows) with different Layout, Controls (ComboBox, simple Input, DateTimes) based on the data that I have. But I don't really know how to go about it? So here in summary: DataGrid 1 Purpose is to display columns that have been specified in DataGrid 2 In rows, the user can add any kind of data in the rows below the columns that is allowed as to the columns specifications DataGrid 2 Each row in this grid represents a column in DataGrid 1 Contains fields like Name/Header, DataType, Validation Behaviour, Default Value, Data Formatting, etc. Also contains a function to be able to set-up how it should be displayed. The user can select from, for instance, ComboBoxColumn (and also add the available options), DateTime, normal TextBox, CheckBox etc. After finishing adding a row it will automatically appear as a new column in DataGrid 1 I'd appreciate any kind of pointer into the right direction. Thanks very, very much in advance! :)

    Read the article

  • How can I bind dynamic data to DataGridTemplateColumn in code?

    - by TuomoT
    I'm using DataGrid from CodePlex. I have objects (ICustomTypeDescriptor) that have properties 'name' 'description' 'c' 'd' and so on (the names are dynamic, and so is the value) and they have information behind them. I have templates for different types. And if I have to list the properties of a single element I can just bind to the values in xaml and use datatemplateselector (in datagridtemplatecolumn) which will pick the correct template. However, when I'm listing several of the elements, how can I use the selectors and the templates? How do I get the correct property bound to the template (two-way)? When ignoring the need for different templates, using DataGridTextColumn with bindings is very simple (and works, see example below), is there any way to use similar approach with the DataGridTemplateColumn? foreach (String propertyName in listOfPropertyNames) { DataGridTextColumn textColumn = new DataGridTextColumn() { Header = propertyName, Binding = new Binding() { Path = new PropertyPath(propertyName) } }; DataGrid.Columns.Add(textColumn); }

    Read the article

1 2 3 4  | Next Page >