A 'Binding' can only be set on a DependencyProperty of a DependencyObject

Hi everyone, I'm trying to create a ToggleSwitch on WPF which based on ToggleButton by using UserControl.
Everything works fine but when I try to bind IsChecked property of a CheckBox to my ToggleSwitch, it throws me an error like the title .
Here is my code :
<UserControl x:Class="CustomControl.ToggleSwitchWPF"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:System="clr-namespace:System;assembly=mscorlib"
Width="Auto"
Height="Auto">
<UserControl.Resources>
<System:Double x:Key="ControlHeight">23</System:Double>
<System:Double x:Key="ControlWidth">50</System:Double>
</UserControl.Resources>
<Grid Name="grdMainGrid"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
MinWidth="{StaticResource ControlWidth}"
MaxWidth="{Binding RelativeSource={RelativeSource Mode=Self}, Path=MinWidth}"
MinHeight="{StaticResource ControlHeight}"
MaxHeight="{Binding RelativeSource={RelativeSource Mode=Self}, Path=MinHeight}">
<!-- This is the main component of this UserControl -->
<ToggleButton Name="tbnMainToggleButton"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Background="{x:Null}"
Click="btnMainToggleButton_Click"
Checked="btnMainToggleButton_Checked"
Unchecked="btnMainToggleButton_Unchecked">
<!-- Customize toggle button's template -->
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<i:Interaction.Behaviors>
<ei:FluidMoveBehavior AppliesTo="Children"
Duration="0:0:0.1">
<ei:FluidMoveBehavior.EaseX>
<SineEase EasingMode="EaseIn" />
</ei:FluidMoveBehavior.EaseX>
</ei:FluidMoveBehavior>
</i:Interaction.Behaviors>
<!-- This is the vertial border which contains the Vertial Bar -->
<Border Name="bdrVertialBarBorder"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
BorderBrush="Gray"
BorderThickness="1"
Grid.ColumnSpan="2">
<!-- This is the background inside the vertical border -->
<Border x:Name="bdrInsideVerticalBorder"
Grid.ColumnSpan="2"
Background="Green"
Margin="2"/>
</Border>
<!-- This is the object which runs from left to right or vice versa to indicate whether is toggle button is checked or not-->
<Border Name="Thumb"
Height="{Binding ElementName=bdrVertialBarBorder, Path=ActualHeight}"
CornerRadius="2"
Background="Black"
Margin="1, 0, 1, 0"
Grid.Column="0"/>
</Grid>
<ControlTemplate.Triggers>
<!-- This trigger is activated when the toggle button is checked -->
<Trigger Property="IsChecked"
Value="true">
<Setter Property="Grid.Column"
TargetName="Thumb"
Value="1"/>
<Setter TargetName="bdrInsideVerticalBorder"
Property="Background"
Value="Red"/>
</Trigger>
<!-- This trigger is activated when the toggle button is disabled -->
<Trigger Property="IsEnabled"
Value="false">
<Setter Property="Opacity"
Value="0.4"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CustomControl
/// <summary>
/// Interaction logic for ToggleSwitchWPF.xaml
/// </summary>
public partial class ToggleSwitchWPF : UserControl, INotifyPropertyChanged
#region Delegates
* Handler of Click Event
public delegate void ClickEventHandler(object sender);
* Handler of Checked event
public delegate void CheckedEventHandler(object sender);
* Handler of Unchecked event
public delegate void UncheckedEventHandler(object sender);
#endregion
#region Delegates' event
* Event of ClickEventHandler
public event ClickEventHandler Click;
* Event of CheckedEventHandler
public event CheckedEventHandler Checked;
* Event of UncheckedEventHandler
public event UncheckedEventHandler Unchecked;
#endregion
#region Properties
* Check whether is ToggleSwitch is checked or not
public bool? IsChecked
get
return tbnMainToggleButton.IsChecked;
set
// Change the check state of Main ToggleButton
tbnMainToggleButton.IsChecked = value;
// Fire the PropertyChanged event
NotifyPropertyChanged("IsChecked");
#endregion
#region Constructor
* Non-parameter constructor
public ToggleSwitchWPF()
InitializeComponent();
#endregion
#region Events
#region ToggleButton
* This event is fired the main ToggleButton is clicked
private void btnMainToggleButton_Click(object sender, RoutedEventArgs e)
// Invalid Click event
if (Click == null)
return;
// Fire the event
Click(sender);
* This event is fired when the main ToggleButton is checked
private void btnMainToggleButton_Checked(object sender, RoutedEventArgs e)
// Invalid Checked event
if (Checked == null)
return;
// Fire the event
Checked(sender);
* This event is fire when that main ToggleButton is Unchecked
private void btnMainToggleButton_Unchecked(object sender, RoutedEventArgs e)
// Invalid Unchecked event
if (Unchecked == null)
return;
// Fire the event
Unchecked(sender);
#endregion
#endregion
#region INotifyPropertyChanged Implementation
* Create an event to fire when a property is changed
public event PropertyChangedEventHandler PropertyChanged;
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged(string propertyName)
// Invalid Event
if (PropertyChanged == null)
return;
// Fire the event
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
#endregion
Can anyone help me to solve this problem please ?
Thank you

You have to implement IsChecked as dependency property. Like you can define as
public bool? IsChecked
    get { return (bool?)GetValue (IsCheckedProperty); }
    set { SetValue (IsCheckedProperty, value); }
public static readonly DependencyProperty IsCheckedProperty
    = DependencyProperty.Register (
        "IsChecked",
        typeof (bool?),
        typeof (ToggleSwitchWPF),
        new FrameworkPropertyMetadata (
            false,
            OnIsCheckedChanged
private static void OnIsCheckedChanged ( DependencyObject src, DependencyPropertyChangedEventArgs e )
    ver switch = src as ToggleSwitchWPF;
    switch.tbnMainToggleButton.IsChecked = e.NewValue as bool?;

Similar Messages

  • I have my iphone 5 set up with Itunes on one computer, but I recently just bought my own computer. How do I set up my Iphone with the new Itunes account? Its telling me it can only be set up with one account. Do I have to delete the other account?

    i have my iphone set up with itunes on one computer, but i recently bought my own computer. How do I set up my iphone with the new itunes account? It says my phone can only be set up woth one itunes account. How do I remove the previous account?

    ThisGal_Drea wrote:
    i have my iphone set up with itunes on one computer, but i recently bought my own computer. How do I set up my iphone with the new itunes account?
    Do you mean iTunes library?
    iTunes account is what you use to make iTunes purcahses.
    iTunes library is what is on your computer.
    It says my phone can only be set up woth one itunes account. How do I remove the previous account?
    No, it tells you it can only be sync'd with one iTunes library.
    Simplest way is to copy the entire /Music/iTunes/ folder (thisis the iTunes library) from old computer to new computer.

  • CAD VIEW Error : "Status can only be set when all originals are stored"

    Hi Friends,
    I have Proe to SAP integrated and when I open Proe model in CAD VIEW and try to create a document it shows an error "Status can only be set when all originals are stored" Also I see that the model is not having Status in CAD VIEW.
    When I double click on that object in CAD VIEW, it takes me to DIR creation screen with Document Type DES. Can someone help me in this  ?
    Rgds,
    SM

    Hello Sudharshan,
    "Status can only be set when all originals are stored" Also I see that the model is not having Status in CAD VIEW.
    This is error is indicating that your original CAD model is not checked in and as per your configuration you require the original to be checked in before moving to next status.
    Please:
    1. Check your document status network.
    2. ensure that you have proper set up for the fields "check in" in the current status. This indicator should be set. This ensures that the document is automatically checked in before moving to the next status. This will solve your problem.
    When I double click on that object in CAD VIEW, it takes me to DIR creation screen with Document Type DES. Can someone help me in this ?
    Because of the above set up missing the original DIR is missing the original document and hence the system assumes you are creating a new DIR when you click on the object in CAD view.
    regards,
    N K

  • Message no. 26269 : Status can only be set when all originals are stored

    Hi,
    While changing status in cv02n, i am getting the below message no-Message no. 26269 : Status can only be set when all originals are stored. I am not getting the message solution in google. please guide me how to come over from this message.
    Regards,
    Mastan.

    Collegues! Have you any idea?
    Found this - [recommendation|http://help.sap.com/saphelp_47x200/helpdata/en/0c/b98e3c90347b17e10000000a114084/content.htm] - how to, but there so simple scenario without details about standart functionality.
    Check In
    You can check in originals, which are saved in the local network, into a storage system. The following originals are indicated by the  icon:
    Originals that are to be checked in for the first time.
    Originals that have already been checked in, and loaded into the local network for changing.
    To do this start WebDocuments. Process the document info record in the change mode.
    Select the original in the Originals dataset.
    Choose Check In. The system determines the storage system based on the system settings, and checks in the original.
    You return to the data sheet. The original application file is indicated by the Checked In  icon.
    Save the document.
    Very simple, but not work, and no details. Castle icon are not locked. DELETE, CANCEL - work, but not CNANGE.
    Maybe my storage system cannot determine the storage system? If it is right, so where can i maintain this option?

  • Is there a way to force time can only be set to "Set date and time automatically"?

    I am using OS X 10.9 .5 , and here is what I want to do.
    When you click "Open Date & Time Preference", you will find an option that states "Set date and time automatically". And of course you can chose not to do that, and adjust the time.
    But can you remove that option? So your OS X is forced to chose the mode "Set date and time automatically" no matter what you do? (aka you can't adjust the time by yourself now.)
    Is that possible? Is there an app that can achieve this goal or can you do that at Terminal?
    Thanks in advance.

    There's a similar setting in iPhoto preferences (in iLife '08 versions and later), or in Image Capture preferences (if you're using iLife '06 or earlier). Check those settings as well.

  • Can only get the "Draft" stamp when insert customer stamp with C#+JS

    I am trying to insert customer stamp in batch files with C#+JS.
    My JS works well in Acrobat. However, it doesn't work when use C#+JS. I always get the Acrobat's "Draft" stamp other than my own ones (the AP value is confirmed correct).
    In c#, it runs as this ( with the objectype.InvokeMember())
    1. initial an annotation with addAnnot first and get the properties object with method of getProp().
    2. Set the type entry of the properties object as "Stamp"
    3. With setProp(), modify the annotation to a Stamp annotation, and then get the properties object of the Stamp annotation.
    4. Set the entries (rect, page, AP ) of the properties object. Then use setProp() again to modify the properties of the Stamp annotation.
    The program runs without any error message. But I can only get the default stamp "Draft".
    One thing I found so far, in JS console in Acrobat, if I set the AP properties AFTER set the annotation type to "Stamp", it also get the "Draft" stamp only. as this,
         annot = this.addAnnot();
         prop = annot.getProps();
         prop.type = "Stamp";
         annot.setProps(prop);
         prop = annot.getProps();
         prop.page = 0;
         prop.rect = [0, 0, 100, 100];
         prop.AP = "#xxxxxxxx";
         annot.setProps(prop);
    If I set the prop.Ap before the forth line in above para, I can get the right stamp.
         annot = this.addAnnot();
         prop = annot.getProps();
         prop.type = "Stamp";
         prop.AP = "#xxxxxxxx";
         annot.setProps(prop);
         prop = annot.getProps();
         prop.page = 0;
         prop.rect = [0, 0, 100, 100];
         annot.setProps(prop);
    Or, if I set the props in the typcial JS format like below, I also get the right one
    annot = this.addAnnot({
    type: stamp,
    page: 0,
    rect: [0,0,100,100]
    AP: #xxxxxxxx)});
    But, the problem is, in C#, the AP properties can only be set after set the annotation type as Stamp (step 4). I think this might be the reason, but I don't know how to get over this.
    Please help. Thanks!

    No, it can't – but you could do that yourself as part of the watermarking process (ie. Two watermarks or fields)
    From: santa-satan <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Mon, 6 Feb 2012 18:35:19 -0800
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Can only get the "Draft" stamp when insert customer stamp with C#+JS
    Re: Can only get the "Draft" stamp when insert customer stamp with C#+JS
    created by santa-satan<http://forums.adobe.com/people/santa-satan> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4190155#4190155

  • In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    In the new mail app for OSX v10.7 Lion it seems I can only setup my gmail account as an "imap", when I need to set it up as "pop"... PLZ HELP I NEED MY MAIL TO WORK!!!

    Go to System prefs
    Select Mail Contacts and Calendars
    Then select Other
    Then select "Add a Mail Account and click create
    Then go to google for the settings you need:
    First here for the settings online at gmail http://tinyurl.com/du3fu
    Then here for the setting in mail http://tinyurl.com/38fevm8
    These are instructions for Mail 4.0 but all of the necessary settings should be listed.

  • I can only see three weeks of emails on the imap email account on my iMac even though the same email address set up as a pop account on my iPhone, iPad and another iMac show all my emails.  How do I change the setting to see more emails?

    I have two iMacs, an iPhone, and an iPad.  All use the same email address but the new iMac would only let me set up the email account as an imap account. On this iMac I can only see three weeks worth of emails.  On the other iMac, iPhone, and iPad, this email address is set up as a pop account and I can see emails as far back as three years.  I use Yosemite on the new iMac and I cannot find out how to change the settings to let me see more than three weeks worth of emails.  This is an att&t email account which is basically a Yahoo account.

    Nope. It will reset all settings. For fix errors.
    Or you can try Logging out and Restart your iPad and Sign in again.

  • With 10.2 I can only use system speaker output for audio, NOT my RME FF400 I used previously. The FF400 works fine with other apps. How can I set this device in FCP 10.2? (it is set in both system preferences and midi)

    With 10.2 I can only use a system (e.g. speaker) output for audio, NOT my RME FF400 I used without any problems previously. The FF400 works fine with other apps (some like TwistedWave) setup in the program, and others (like Spotify) using system preferences & audio midi setup. How can I set the FF400 to be the sound output device in FCP 10.2? N.B. The FF400 is set as sound output device in both system preferences and audio midi setup.

    From the fcp.co forum. See if this does anything for you.
    simon_hutchings
    OFFLINE
    Junior Boarder
    Posts: 24
    Thank you received: 5
    Karma: 1
    I have the solution! Well it at least worked for me. This is the response I got from Apple, Can you please try the following steps towards fixing your audio issue, and report back with your results?
    1. Open the application Audio Midi Setup (located in Applications : Utilities)
    2. Select the Output Tab for the current output device
    3. Select the Configure Speakers option
    4. Select the Multichannel tab
    5. Change the setting to Stereo Now mine was set to stereo but the left channel wasn't showing left. re-clicking on stereo reloaded the settings and after clicking apply it worked. 

  • ITunes tells me "Could not be used because the original file could not be found. Would you like to locate it?"  I can locate it and all my other music, but can only open one song at a time.  How do I set it to open all my music whenever I want it?

    iTunes tells me my song selection: "Could not be used because the original file could not be found. Would you like to locate it?"  I can locate it and all my other music, but can only open one song at a time.  How do I set it to open all my music whenever I want?
    Message was edited by: Woildbill

    I just spent several hours dealing with this when switching to a new PC. It was extremely frustrating as I knew my files were on my external HD but no matter how many times I copied my old iTunes folder over the files were still missing...because dummy me had forgotten to "unhide folders" on my new PC and my old files were actually stored in a hidden folder created long long ago.
    This is how I did it on Windows 7 with iTunes 10
    1. Look in iTunes Advanced Preferences to see where iTunes is saving files. (Edit, Preferences, Advanced)
         Example: C:/Users/Woildbill/My Music/iTunes/Music
    2. Ensure you are able to see hidden files - Control Panel, Folder Option, View, Show Hidden Files
    3. Use Your Computer's Search Function to Locate the Missing File (Start, Search, type name of song - I started my search in "My Music" folder but be sure to expand to entire Computer if not found right away)
    4. In Search Results, right-click found folder and select properties. This will tell you where the file is actually stored.
    5. Use Windows Explorer (right-click start) to navigate to the location of the file. It is likley your other missing files are in the same location.
    6. In Windows Explorer, copy the newly located files to the iTumes location from Step 1 and everything should work again.
    Hope this helps!

  • Bind variable only can take valor one time?

    Can you help me about the different results in "SQL Developer" and "SQL*Plus" with bind variable's management?
    I execute next code. My table emp have 14 records.var n_fetch number;
    var n_rowcount number;
    declare
    cursor S is
    select emp_no from emp;
    v_emp_no emp.emp_no%type;
    begin
    :n_fetch := 0; -- (1)
    open S;
    fetch S into v_emp_no;
    while S%found loop
    :n_fetch := :n_fetch + 1;
    fetch S into v_emp_no;
    end loop;
    :n_rowcount := S%rowcount;
    close S;
    end;
    print n_fetch n_rowcount
    In SQL*Plus, the result is:N_FETCH
    14
    N_ROWCOUNT
    14
    In SQL Developer, the result is:n_fetch
    0
    n_rowcount
    14
    If I change instruction (1) for: :n_fetch := 100;
    then, in SQL*Plus the result is correct (n_fetch=114 and n_rowcount=14) but in SQL Developer, attention, the result is:
    n_fetch
    100
    n_rowcount
    14
    Conclusion: Bind variable only can take valor one time !!!
    What happen's in SQL Developer? I work with Oracle SQL Developer 1.5.1.
    Thanks, very much
    Isidre Guixà

    Isidre,
    This is the same problem as I just highlighted on your other thread (Error in dbms_output with bind variables ? - basically only the first assignment per PL/SQL block seems to have an effect.
    theFurryOne

  • Can Captivate be set to advance when only a certain key is pressed

    I am doing software training simulation.  I am trying to teach the user how to do a set of tasks.  In the software you must press certain key to accomplish certain steps so  I want to set captivate to advance to the next slide only when the correct key is pressed such as the delete key. I am fairly new with captivate. Is this possible? Will I need an advanced action to do this?  Thanks

    Each interactive object, like a Click box, can be assigned a shortcut key. If you are capturing the software training simulation (Automatic), those click boxes are created for you. In the Properties panel of the Click box you can assign the shortcut key. Normally you do not need an advanced action for that. And be sure to give Infinite Attempts if the user can only proceed when that shortcut key is pressed (but avoid frustration, maybe with the Hint caption?)
    Lilybiri

  • Can icloud be set to only copy/save music files?

    I would rather not have this program copyng all my photos, documents and looking for all of my so called 'freinds' - can it be set up to only copy/save my music and audio books?

    Welcome to the Apple Community.
    iCloud sync services are nothing to do with your music and books, you don't need to enable calendar, contact etc syncing to take avantage of iTunes in the cloud services.
    Additionally you can turn on/off individually any of the sync services if you chose to enable iCloud sync services.

  • Can iTunes be set to play only one song and then stop when the song is finished and not go on to play another unless commanded?

    Can iTunes be set to play only one song and then stop when the song is finished and not go on to play another unless commanded?

    If you uncheck all of the songs, they will only play if explicitly commanded. Command-click in a checkbox and they will all be unchecked. Command-clicking again will check the all again should you want to do that.

  • How do I set up a rating scale so that respondents can only select each option one time?

    How do I set up a rating scale so that respondents can only select each option one time?

    hi there,
    in the LV VI, function & how-to help open the item
    Building the front panel -> Front panels controls and indicators -> Array & Cluster controls and indicators -> Arrays -> Tabbing through Elements of an Array or Cluster
    or see attachment
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    TabbingThroughArrays_Help.jpg ‏96 KB

Maybe you are looking for

  • Jdeveloper error while running a page

    Hi All, I am using 10.1.3.3.0.3 Jdev. I am trying to run a page using Jdev but I am getting below error. I can run the tutorial page successfully but when I try to run other page then it gives me error. I am trying to run below page- /oracle/apps/icx

  • Word 2008 crashes when pfd files are inserted

    I wonder if anyone at Apple are looking into the issue that seem to be confirmed by many reports in different forums: That Word 2008 do crash if a pdf document is inserted into a document saved in the .doc format - not the never .docx format. Some ha

  • Date of Last Delivery incorrect in EKEK (sometimes)

    Hello! When I go into ME39 and into the Release Documents, I have correct dates for Last GR (EKEK-LWEDT) but for Last Delivery, it shows me the date (and number) of what was probably the first Delivery received for that contract. (EKEK-LFDKD / LFNKD)

  • If Ctrl+Alt+Shift buttons not working to reset your adobe photoshop cs5.1 preference to default

    How to reset Photoshop preferences (In Windows): First, hold down all three Ctrl+Alt+Shift buttons Now "while keeping those button held," simply open Photoshop or a file that opens with Photoshop As Photoshop loads, you should get a prompt asking if

  • Provide Feedback for the Logic Pro User Manual and Onscreen Help Here

    The Apple documentation team for Logic Pro would like to know what you think about the Logic Pro Help documentation (available in the Help menu): • How often do you use Logic Pro Help? Under what circumstances do you use it most? • Do you use the pri