2
<DataGridTemplateColumn Header="{x:Static Resources:AppStrings.Tree}">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Controls:MBFontAwsome MBForeground="{DynamicResource SideBar.Icon.Normal}" MBFontsType="lockIcon" Visibility="{Binding RevLock, Converter={StaticResource BoolToVisibilityConverter}}" MBFontSize="12" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

I have written the above code to bind a font awesome to a DataGrid Template Column using XAML.

This works fine and now um in the verge of doing the same thing using Code behind file . So far I have tried up to this level

var projectDocumentColumnHeaderWidth = new DataGridLength(1.0, DataGridLengthUnitType.SizeToHeader);
var collectionToBoolConverter = new CollectionToBooleanConverter();
        /**************************************************************************************/
var faw = new MBFontAwsome();
faw.MBFontsType = MBFonts.documents;
faw.MBFontSize = 12;
faw.Visibility = Visibility.Visible;
var widh = new DataGridLength(1.0, DataGridLengthUnitType.SizeToHeader);
        /***************************************************************************************/
var templateColumn = new DataGridTemplateColumn()
{
    Header = "AttachedProjectDocumentList",
    SortMemberPath = "AttachedProjectDocumentList",
    IsReadOnly = true,
    CellTemplate = new DataTemplate
    {

    }
};
templateColumn.Width = widh;
DoorsGrid.Columns.Add(templateColumn);

How may I bind a font awesome to a cell ?

uTeisT
  • 2,256
  • 14
  • 26
not 0x12
  • 19,360
  • 22
  • 67
  • 133
  • Can't say I'm experienced with font awesome but have you checked [this](http://stackoverflow.com/questions/23108181/changing-font-icon-in-wpf-using-font-awesome) ? *Edit: And also [this](http://stackoverflow.com/questions/21374349/add-icon-font-in-wpf) – uTeisT Aug 15 '16 at 07:40
  • Try to check [this](http://stackoverflow.com/questions/1754608/what-is-the-code-behind-for-datagridtemplatecolumn-and-how-to-use-it), you need to change `CheckBox` to `MBFontAwsome` and add binding of specified types. *Edit: you don't need bind it to, you need to add it to visual-tree. – Shakra Aug 15 '16 at 08:34

0 Answers0