int decimalPoints=BitConverter.GetBytes(Decimal.GetBits(value)[3])[2];
This blog is primarily a compilation of frequently faced issues by developers with solutions which I have implemented to solve them
Monday, October 19, 2015
C# code to get numbers after decimal point
Labels:
C#,
Decimal Precision
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Saturday, October 10, 2015
How do you force authors or template stylists to force add a control
How do you force
authors or template stylists to force add a control
Solution- Provides
template authors the information that these parts are required for styling this
control -more like a contract
[TemplatePart [Name=TextBlockPart, Type =typeof(TextBlock))) public class MyControl : Control
{ private const string TextBlockPart as PART_TextBlock; TextBlock textblock; protected TextBlock Textßlock get { return textblock;} set { if (textßlock is null) ( textblock.Textlnput-= new TextCompositionEventHendler(textblockTextlnput) J
Labels:
Custom Control,
Template Part,
WPF
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Access TemplatedElements in CustomControl
How to access
TemplatedElements in CustomControl?
Override OnApplyTemplate in the .cs file. Its called everytime
a template is applied to a control
public override void OnApplyTenplate()
public override void OnApplyTenplate()
{ base.OnApplyTemplate(); var textblock= GetTemplateChild("Name Of Part") as TextBlock; textblock.Text="hello";
}
Labels:
Custom Control,
TemplatedElements,
WPF
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
How to get two way binding with Template Binding in WPF
Template Binding by default doesnt support Two Way binding.
If you still need to have it, here's the workaround:
<TextBox Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}"/>
If you still need to have it, here's the workaround:
<TextBox Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}"/>
Labels:
TemplatedParent,
TwoWay Binding,
WPF
Solution Architect employed with Mercedes Benz with about 14 years of experience in Microsoft Technologies.
Subscribe to:
Posts (Atom)