Click here to Skip to main content
15,867,756 members
Home / Discussions / WPF
   

WPF

 
QuestionHandling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z27-Jan-14 23:43
Piotr Z27-Jan-14 23:43 
AnswerRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 0:29
subeditorPete O'Hanlon28-Jan-14 0:29 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z28-Jan-14 0:51
Piotr Z28-Jan-14 0:51 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 1:10
subeditorPete O'Hanlon28-Jan-14 1:10 
AnswerRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
_Maxxx_2-Feb-14 19:36
professional_Maxxx_2-Feb-14 19:36 
QuestionProblems updating datagrid from collection Pin
abollmeyer23-Jan-14 10:55
abollmeyer23-Jan-14 10:55 
AnswerRe: Problems updating datagrid from collection Pin
Mycroft Holmes23-Jan-14 12:04
professionalMycroft Holmes23-Jan-14 12:04 
QuestionBinding property from XML file data Pin
abollmeyer21-Jan-14 9:18
abollmeyer21-Jan-14 9:18 
I am trying to read from an XML file and populate the data to a datagrid. All of the data is being populated, but I want to change the background color when a checkbox in a checkbox column is checked. This works when I select the checkbox with mouse, but not when reading from XML file, even though the checkbox shows true. Here is my code:

Datagrid Row Style:

HTML
<<pre>Style x:Key="dataGridRowStyle" TargetType="DataGridRow">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Checked}" Value="True">
                        <Setter Property="Background" Value="LightGray"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style
>

Datagrid definition:

HTML
<<pre>DataGrid Name="amortizationSchedule" ItemsSource="{Binding}" AutoGenerateColumns="False" HorizontalContentAlignment="Center" CanUserAddRows="False" HorizontalScrollBarVisibility="Auto" RowStyle="{StaticResource dataGridRowStyle}" DockPanel.Dock="Top">
                        <DataGrid.Resources>
                            <Style TargetType="DataGridCell">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="DataGridCell">
                                            <Grid Background="{TemplateBinding Background}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <Style TargetType="DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </DataGrid.Resources>
                        <DataGrid.Columns>
                            <DataGridCheckBoxColumn Header="Paid?" Binding="{Binding Checked, Mode=TwoWay}" CanUserReorder="False" CanUserSort="False" CanUserResize="False"/>
                            <DataGridTextColumn Header="Payment #" Binding="{Binding monthlyPaymentNumber}" MaxWidth="150" Width="Auto" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Payment Date" Binding="{Binding monthlyPaymentDate}" MaxWidth="150" Width="*" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Payment Amount" Binding="{Binding monthlyPaymentAmount}" MaxWidth="150" Width="Auto" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Principle Portion" Binding="{Binding monthlyPrinciplePortion}" MaxWidth="150" Width="*" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Interest Portion" Binding="{Binding monthlyInterestPortion}" MaxWidth="150" Width="*" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Ending Balance" Binding="{Binding monthlyEndingBalance}" MaxWidth="150" Width="*" CanUserReorder="False" CanUserSort="False" CanUserResize="False" IsReadOnly="True"/>
                            <DataGridTextColumn Header="Extra Payments Paid to Principle" Binding="{Binding monthlyExtraPaymentsToPrinciple}" Width="*"/>
                        </DataGrid.Columns>

                    </DataGrid
>


C# Code behind, reading from XML:

C#
if (File.Exists(myXMLPath))
            {
                DataSet ds = new DataSet();
                dt = new DataTable();
                dt.TableName = "dataTable";
                ds.ReadXml(myXMLPath);
                this.DataContext = ds.Tables[0].DefaultView;
            }

AnswerRe: Binding property from XML file data Pin
abollmeyer21-Jan-14 14:44
abollmeyer21-Jan-14 14:44 
QuestionCombobox / Textblock field Pin
eddieangel21-Jan-14 6:24
eddieangel21-Jan-14 6:24 
AnswerRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 7:52
professionalJason Gleim21-Jan-14 7:52 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 8:07
eddieangel21-Jan-14 8:07 
GeneralRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 8:48
professionalJason Gleim21-Jan-14 8:48 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 9:14
eddieangel21-Jan-14 9:14 
GeneralRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 9:42
professionalJason Gleim21-Jan-14 9:42 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 10:12
eddieangel21-Jan-14 10:12 
GeneralRe: Combobox / Textblock field Pin
Jason Gleim21-Jan-14 10:25
professionalJason Gleim21-Jan-14 10:25 
GeneralRe: Combobox / Textblock field Pin
eddieangel21-Jan-14 11:29
eddieangel21-Jan-14 11:29 
GeneralRe: Combobox / Textblock field Pin
Jason Gleim22-Jan-14 4:28
professionalJason Gleim22-Jan-14 4:28 
GeneralRe: Combobox / Textblock field Pin
eddieangel22-Jan-14 5:34
eddieangel22-Jan-14 5:34 
QuestionHow to stop repeating animation Pin
Member 1001614016-Jan-14 12:25
Member 1001614016-Jan-14 12:25 
AnswerRe: How to stop repeating animation Pin
Varsha Ramnani20-Jan-14 22:41
professionalVarsha Ramnani20-Jan-14 22:41 
QuestionWPF Checkbox Binding Question Pin
Kevin Marois10-Jan-14 8:38
professionalKevin Marois10-Jan-14 8:38 
AnswerRe: WPF Checkbox Binding Question Pin
Meshack Musundi12-Jan-14 8:28
professionalMeshack Musundi12-Jan-14 8:28 
AnswerRe: WPF Checkbox Binding Question Pin
eddieangel21-Jan-14 7:53
eddieangel21-Jan-14 7:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.