Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tooltip only showing for less than 1 second
#1
Sample code:

C# code:
var b = new wpfBuilder("Window");

b.R.Add<Label>("PTP Domain").AlignContent(HorizontalAlignment.Right);
b.Add<TextBox>(out TextBox ptpDomain).AlignContent(HorizontalAlignment.Left).Tooltip("Integer between 0 and 127");

b.R.Add<Label>("Delay Request").AlignContent(HorizontalAlignment.Right);
b.Add<ComboBox>(out ComboBox ptpDelayReq).Items("Multicast|Unicast");

b.R.Add<Label>("Control Multicast AddressTongueort").AlignContent(HorizontalAlignment.Right);
b.Add<TextBox>(out TextBox controlMC).Tooltip("Control MC").Tooltip("Port must 49999");

b.R.AddOkCancel();
if (!b.ShowDialog()) return;


Regardless of what element has focus (if I click in one of the text boxes), I get inconsistent results with how long the tooltip displays.  Sometimes I get the normal 5000ms display time.  Most of the time it flashes for a moment.  Not even long enough to read.  Any ideas?  I tried using the ToolTipService to set the show duration globally to Int32.MaxValue as someone suggested on stack overflow.  Also tried setting it to just 5000.  Same behavior.
#2
Don't know, here works well.

----

The code can be simplified.

C# code:
// script ""
using System.Windows.Controls;

var b = new wpfBuilder("Window");
b.Options(rightAlignLabels: true);

b.Add("PTP Domain", out TextBox ptpDomain).Tooltip("Integer between 0 and 127");

b.Add("Delay Request", out ComboBox ptpDelayReq).Items("Multicast|Unicast");

b.Add("Control Multicast Address:Port", out TextBox controlMC).Tooltip("Port must 49999");

b.R.AddOkCancel();
if (!b.ShowDialog()) return;

And can validate.

C# code:
// script ""
using System.Windows.Controls;

var b = new wpfBuilder("Window");
b.Options(rightAlignLabels: true);

b.Add("PTP Domain", out TextBox ptpDomain)
    .Tooltip("Integer between 0 and 127")
    .Validation(_ => ptpDomain.Text.ToInt(out int i1) && i1 is >= 0 and <= 127 ? null : "Domain must be integer between 0 and 127");

b.Add("Delay Request", out ComboBox ptpDelayReq).Items("Multicast|Unicast");

b.Add("Control Multicast Address:Port", out TextBox controlMC)
    .Tooltip("Port must 49999")
    .Validation(_ => controlMC.Text.ToInt() is 49999 ? null : "Port must be 49999");

b.R.AddOkCancel();
if (!b.ShowDialog()) return;
#3
That was going to be my next question.... validation.  I assume that lambda just returns null if valid and a string if invalid.... then I could specify a regular expression to the input as well?

Interesting on the tooltip.  I'll try on another machine and see if it was just something weird with that workstation.

Thanks for the simplification too Smile
#4
Is there a way to trigger validation on a Button instead of with just Ok/Cancel?

In another app I extensively use Buttons with a callback function so the overall window stays open and doesn't close.  Also, the user may submit more than once.
#5
Two ways.

C# code:
b.AddButton("Button", _ => { print.it("clicked"); }, WBBFlags.Validate); //or WBBFlags.Apply
b.R.AddOkCancel(apply: "Apply");


Forum Jump:


Users browsing this thread: 1 Guest(s)