I start this question with the remark that Syncfusion sent me a full working program where I can modify the lay-out of their libabry's Kanban cards and also tooltips on it.
For that they simply have this code in the MainWindow code behind:
Code: Select all
kanban.ToolTipTemplate = new DataTemplate()
{
VisualTree = new FrameworkElementFactory(typeof(KanbanToolTipView))
};
When I add a tooltip to a WPF XAML page, it works and I can change the lay-out. But I started from a Syncfusion sample where everything is created from code, there's only a basic MainWindow.XAML.
So I found a possible solution by creating a Dictionay.xaml, as follows:
Code: Select all
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
<StackPanel>
<TextBlock Text="This works"></TextBlock>
</StackPanel>
</Style>
</ResourceDictionary>1 Using a converter
Code: Select all
<TextBlock Text="{Binding ElementName=txtValue, Path=Text, Converter={StaticResource YourConverter}}"></TextBlock>Code: Select all
public class YourConverter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return "XXX";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
2 I can define something like public class MyData : INotifyPropertyChanged with Get/Set and PropertyChangedEventHandler etc. but it's not clear what I need to do in this textblock to trigger that event.
At least:
<TextBlock FontFamily="Tahoma" FontSize="11" Text="{Binding Path=MainWindow.cTest}" Foreground="#FFFFFFFF" />
is not enough to show the value of a public variable cTest
3 I found this code and named the Textblock TT
Code: Select all
var dictionary = new ResourceDictionary
{
Source = new System.Uri("Dictionary.xaml", System.UriKind.Relative)
};
if (dictionary["TT"] is TextBlock ttb)
{
ttb.Text = "Your tooltip text from codebehind";
}Code: Select all
if (dictionary["TT"] is TextBlock ttb) For xxx in Text="{TemplateBinding xxx"} I can select the following options: but these do not seemed to be documented together so I can't find what to do with it.
As said, I can no doubt solve the actual problem with Syncfusion's sample code. But I still wonder why none of the above solutions work. If anyone can comment on that, I would appreciate that.
Dick

