SetBinding (Code hinter) funktioniert nicht, textBlock.text wird gelöschtC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 SetBinding (Code hinter) funktioniert nicht, textBlock.text wird gelöscht

Post by Anonymous »

Ich habe ein kleines Testprojekt erstellt, um einfach mein Problem zu veranschaulichen. behind, highlighting information is added to the Inlines of the TextBlock
[*]Because of DataGrid with VirtualizingStackPanel.VirtualizationMode="Recycling" the result of GetBindingExpression(TextBlock.TextProperty) is Null im Ereignis datagrid.onloadingrow aber auch im Ereignis datagridrow.LODED
[*] Ich habe jetzt versucht, den -Bindeln
[*] zurückzusetzen. Bindung.

Ich hoffe, Sie können mir helfen, damit der Text nach dem Einstellen der -Bindung .

Code: Select all



Code hinter

Code: Select all

// Save data for binding
var exp = txtBlock.GetBindingExpression(TextBlock.TextProperty);
txtBlock.Tag = new Tuple(exp.ParentBinding.RelativeSource, exp.ParentBinding.Path)

var inlines = new List();
inlines.Add(new Run(text.Substring(0, 1)));
inlines.Add(new Run(text.Substring(1, 2))
{
Background = filterData.SelectionColor,
Foreground = filterData.ForegroundColor
});
inlines.Add(new Run(text.Substring(3, 1)));

txtBlock.Inlines.Clear();
txtBlock.Inlines.AddRange(inlines);
Im Ereignis

Code: Select all

var tagData = (Tuple) txtBlock.Tag;

var binding = new Binding { RelativeSource = tagData.Item1, Path = tagData.Item2};
txtBlock.SetBinding(TextBlock.TextProperty, binding);    //

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post
  • Awk, um einen Textblock zu extrahieren
    by Anonymous » » in Linux
    0 Replies
    8 Views
    Last post by Anonymous
  • Awk, um einen Textblock zu extrahieren
    by Anonymous » » in Linux
    0 Replies
    4 Views
    Last post by Anonymous
  • Awk, um einen Textblock zu extrahieren
    by Anonymous » » in Linux
    0 Replies
    5 Views
    Last post by Anonymous
  • Awk, um einen Textblock zu extrahieren
    by Anonymous » » in Linux
    0 Replies
    6 Views
    Last post by Anonymous
  • Ein Bild hinter Text in einen einzelnen Grenze legen
    by Anonymous » » in HTML
    0 Replies
    0 Views
    Last post by Anonymous