locked
Bold label of PercentViewer RRS feed

  • Question

  • I currently have the following code:

            Private Sub BoldLabel(ByVal sender As Object, ByVal e As ControlAvailableEventArgs)
                Dim textBox = TryCast(e.Control, Control)
                Dim root = VisualTreeHelper.GetRoot(textBox)
                Dim label = root.GetChildrenByType(Of TextBlock)().Where(Function(textBlock) Equals(textBlock.DataContext, textBox.DataContext)).First()
                label.Foreground = New SolidColorBrush(Colors.Black)
                label.FontWeight = FontWeights.Bold
            End Sub

    that was derived from Jewel Lambert's blog post here:

    http://jewellambert.com/using-visualtreehelper-to-perform-lightswitch-wizardry/

    I am attempting to bold the label of a "PercentEditor" but get the following error message 

    "Sequence Contains no Elements"

    on the line:

    Dim label = root.GetChildrenByType(Of TextBlock)().Where(Function(textBlock) Equals(textBlock.DataContext, textBox.DataContext)).First()

    I suspect it has something to do with the TextBlock and that this isnt actually a textblock or something but cant seem to figure it out?

    Any ideas area greatly appreciated?

    I meant percenteditor, not viewer.
    • Edited by Voyagr12 Thursday, June 26, 2014 3:32 PM
    Thursday, June 26, 2014 3:19 PM

All replies

  • Nobody has anything?  Aren't we supposed to get a guaranteed reply within so much time of posting a question?
    Tuesday, July 1, 2014 1:38 AM