Hex stringformat in XAML RRS feed

  • Question

  • Hello,

    In My application , i want to display hex string for a ulong value using XAML.
    I am using StringFormat in xaml but its not working. This is the syntax i am using:
    Content="{Binding CRC, StringFormat=\{0:X8\}}"

    Here CRC is a ulong property.

    I want to dispay the hex value in following format: 0x000FEABC



    Wednesday, December 18, 2013 5:19 AM


  • Hi, you can use StringFormat to achieve that (see here for more info on the hex format). You will have to add the 0x prefix manually as below.

     <TextBlock Text="{Binding Path=MyProperty,StringFormat={}0x{0:X8}}"/>

    • Proposed as answer by Srithar Wednesday, December 18, 2013 7:01 AM
    • Marked as answer by IamHuM Sunday, December 22, 2013 1:31 PM
    Wednesday, December 18, 2013 5:52 AM