locked
Selected value mismatch in Blend (4) UI and XAML RRS feed

  • Question

  • New to blend, so forgive me if this is normal behavior and I'm just missing something...

    I was going through some tutorials in a Silverlight book.  I was instructed to select a font size of 14pt.  I did so and then looked at the XAML and noticed that it had entered a font size of 18.667.  I thought that strange as I couldn't have selected the wrong value from the combobox since there is no 18.667 in there.

    Whatever...  I corrected the value in the XAML to 14 and noticed that the value now represented in the Blend UI is 10.5pt

    I've noticed some other funkiness with comboboxes in the Blen UI...  Several times the comboboxes dont close when I select a value and I can't get to the items under the drop down window.

    I've got the system patched to the latest updates, as far as I know...

    Is this a known issue?

    Thanks.

    J

    Wednesday, January 11, 2012 5:26 AM

Answers

  • This happens because the FontSize attribute uses pixels as its default unit, not points. When you select "14pt" in the dropdown, it converts that to the default value and sets it appropriately. It looks strange, but that's just how things work behind the scenes. If you'd rather things look consistent, you can manually change your XAML to have FontSize="14pt", but changing the font from the dropdown will make the property revert to its value in pixels.

    Here's the MSDN page on FontSize for more information on possible values: http://msdn.microsoft.com/en-us/library/system.windows.documents.textelement.fontsize.aspx

     

    Regarding your combobox issues, could you be more specific? Does it happen on particular boxes? Is it consistently happening on the same box? More information would be helpful.


    • Proposed as answer by Brian Hilstrom Wednesday, January 11, 2012 1:47 PM
    • Unproposed as answer by Brian Hilstrom Wednesday, January 11, 2012 1:49 PM
    • Edited by Brian Hilstrom Wednesday, January 11, 2012 1:50 PM
    • Marked as answer by rlrcstr Wednesday, January 11, 2012 2:49 PM
    Wednesday, January 11, 2012 1:44 PM

All replies

  • This happens because the FontSize attribute uses pixels as its default unit, not points. When you select "14pt" in the dropdown, it converts that to the default value and sets it appropriately. It looks strange, but that's just how things work behind the scenes. If you'd rather things look consistent, you can manually change your XAML to have FontSize="14pt", but changing the font from the dropdown will make the property revert to its value in pixels.

    Here's the MSDN page on FontSize for more information on possible values: http://msdn.microsoft.com/en-us/library/system.windows.documents.textelement.fontsize.aspx

     

    Regarding your combobox issues, could you be more specific? Does it happen on particular boxes? Is it consistently happening on the same box? More information would be helpful.


    • Proposed as answer by Brian Hilstrom Wednesday, January 11, 2012 1:47 PM
    • Unproposed as answer by Brian Hilstrom Wednesday, January 11, 2012 1:49 PM
    • Edited by Brian Hilstrom Wednesday, January 11, 2012 1:50 PM
    • Marked as answer by rlrcstr Wednesday, January 11, 2012 2:49 PM
    Wednesday, January 11, 2012 1:44 PM
  • Thanks, Brian.  Should have thought of that...  I did try entering "14pt" directly in the XAML, but it complained that it wasn't a valid double value.

    J

    Wednesday, January 11, 2012 2:50 PM