Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5
Create tooltip in code behind using a tooltip structure from XAML
posted

Instead of tooltip with 2 lines i see hint of mouse roll over. Can someone help me plz? Bindings can only be done in codebehind

XAML- Grid.Resources








xaml.cs

private void SetStyle()
{
Style _rightAlignedstyle = CreateOpenOrderStyle($"{nameof(DataRecord.DataItem)}.{nameof(RIViewModel.Node)}", (Style)_grid.TryFindResource("CellValuePresenterStyle"));
_grid.FieldLayouts[0].Fields[4].Settings.CellValuePresenterStyle = _rightAlignedstyle;
}

private Style CreateOpenOrderStyle(string node_, Style basedon_)
{

var _RMTooltip = (ToolTip)_grid.TryFindResource("RMTooltip")
Style style = new Style { TargetType = typeof(CellValuePresenter), BasedOn = basedon_ };
var stackPanel_ = (Panel)_RMTooltip.Content;

var children_ = stackPanel_.Children;
if (children_.Count == 2)
{
var descriptionTxtBlock = (TextBlock)children_[0];
descriptionTxtBlock.SetBinding(TextBlock.TextProperty, new Binding($"{node_}.{nameof(INode.Description)}"));
var settleTxtBlock = (TextBlock)children_[1];
settleTxtBlock.SetBinding(TextBlock.TextProperty, new Binding($"{node_}.{nameof(INode.TradePx)}"));
}

style.Setters.Add(new Setter(CellValuePresenter.ToolTipProperty, _RMTooltip));
return style;
}

Parents
No Data
Reply Children
No Data