Showing posts with label xaml. Show all posts
Showing posts with label xaml. Show all posts

Wednesday, February 22, 2012

XAML Control to Control Binding

I have a control that I want to enable/disable based on a checkbox.  I ended up using a binding with ElementName and Path:

<CheckBox 
x:Name="Enabler" />

<ComboBox
IsEnabled="{Binding ElementName=Enabler,Path=IsChecked}" />

Tuesday, February 21, 2012

Add a ToolTip in Code

Today I had to create many controls in code (not XAML).  I wanted to add tooltips as I created them:
void AddManyControls()
{
    var control = new Control();
    ToolTip toolTip = new ToolTip 
    { 
        Content = "ToolTip Content"
    }

    ToolTipService.SetToolTip(control, toolTip); 
}