Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Excuse me for my English, i'm from Russia, the problem my code associated with tooltip in the table Datagrid on the cell. The code has one moment (FallbackValue), but there are two in it but at least for me:
1. Cannot get the color to change the FallBackValue, and if it changes after the record stays attached to the color of the FallBackValue
2. If you place the cursor in a cell for editing, FallbackValue disappears in all other cells.
Help solve the problem, of course if I went the right way.
Thank you.

My code:

C#
<pre>public partial class MainWindow : Window
    {
        ObservableCollection<Person> person = new ObservableCollection<Person>();
        public MainWindow()
        {
            DataGridCell cell = new DataGridCell();
            InitializeComponent();
            if (person == null)
                person = new ObservableCollection<Person>();
            DGR.ItemsSource = person;
        }
C#


C#
class Person
   {
       private string name;
       private string secondName;
       public string Name
       {
           get { return name; }
           set
           {
               name = value;
           }

       }
       public string SecondName
       {
           get { return secondName; }
           set
           {
               secondName = value;
           }
       }

HTML
<pre><DataGrid x:Name="DGR" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Text" Value="{Binding Name, FallbackValue=Name}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>

                    <DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="Text" Value="{Binding Name,
                            ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/>
                        </Style>
                    </DataGridTextColumn.EditingElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Header="SecondName">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="Text" Value="{Binding SecondName, FallbackValue=SecondName}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>

                    <DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="Text" Value="{Binding SecondName,
                            ValidatesOnDataErrors=True, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/>
                        </Style>
                    </DataGridTextColumn.EditingElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>


What I have tried:

Options tried, ElementStyle, EditingElementStyle, in textBlock set FallBackValue=, like text in a new line appears, but after editing remains the color that refers to FallBackValue.
Posted
Updated 13-Sep-18 2:35am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900