Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

new to xaml

$
0
0

I have a working datagrid.  I don't believe it's overly complicated.  I want to be able to add a row to the grid, and make that row editable by the user.

I have the code that successfully adds the row, but I can't get the ability to edit.

Note that I really only need the Title field editable, so I did provide for a celltemplate and for a celleditingtemplate.

<UserControl x:Class="DocumentListing"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"><Grid><Border BorderThickness="0,0,0,0" Width="Auto" Height="Auto" DockPanel.Dock="Top,Left"  ><Grid><Grid.RowDefinitions><RowDefinition Height="30"/><RowDefinition Height="*" /></Grid.RowDefinitions><Button x:Name="btnNew" Content="New"
                VerticalAlignment="Top"
                        HorizontalAlignment="Left"
                        Width="60"
                        Height="25"
                        Margin="3"
                Click="btnNew_Click"/><Button x:Name="btnGetData" Content="Get Data"
                VerticalAlignment="Top"
                        HorizontalAlignment="Right"
                        Width="60"
                        Height="25"
                        Margin="3"
                Click="btnGetData_Click"/><DataGrid Name="dataGrid1" IsReadOnly="True" AutoGenerateColumns="False"
                      AlternatingRowBackground="#eee" Grid.Row="1" CanUserAddRows="True"
                              ItemsSource="{Binding TrimData, Mode=TwoWay}"
                              SelectionChanged="GridSelectionChanged"><DataGrid.ColumnHeaderStyle><Style TargetType="{x:Type DataGridColumnHeader}"><Setter Property="FontWeight"
                                    Value="Bold" /><Setter Property="Background" Value="#d0d0d0" /><Setter Property="Height" Value="35" /><Setter Property="Padding" Value="4"/><Setter Property="HorizontalContentAlignment" Value="Center" /></Style></DataGrid.ColumnHeaderStyle><DataGrid.Columns><DataGridTemplateColumn><DataGridTemplateColumn.CellTemplate><DataTemplate><Button Click="ViewButtonClick" Tag="{Binding Path=RecNumber}"
                                                        VerticalAlignment="Center"
                                                        HorizontalAlignment="Center"
                                                        Width="23"
                                                        Height="23" ><Image Source="/RbdmsWpfControlsBase;component/images/View.png" /></Button></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTemplateColumn Header="Document Name" MinWidth="300" SortMemberPath="Title"><DataGridTemplateColumn.CellTemplate><DataTemplate><TextBlock Text="{Binding Title}" /></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><TextBox Text="{Binding Title}"/></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn><DataGridTextColumn Header="Type" Binding="{Binding FileExtension}" MinWidth="50"></DataGridTextColumn><DataGridTextColumn Header="Upload Date" Binding="{Binding DateCreated}" MinWidth="100"></DataGridTextColumn></DataGrid.Columns></DataGrid></Grid></Border></Grid></UserControl>


Stockton


Viewing all articles
Browse latest Browse all 18858

Trending Articles