I have few textblocks, with custom font family which work fine:
FontFamily="{StaticResource CodeBold}"
This is XAML way (working one), but I want to do same thing in C#, I guess I missed something big.
TextBlock txTop = new TextBlock();
txTop.FontFamily = new FontFamily("CodeBold");
How to do this in C#?
CodeBold is the name of your resource and not of the Font Family. That’s why that doesn’t work. What you need to do is assign the resource to the Font Family. The following code should work for your circumstance.
More information on FindResource is on MSDN.