I do not know why there are not data bindings for some objects in my Silverlight 4 application. Here's almost my XML Looks like:
& lt; Sdk: DataGrid & gt; & Lt; U: Command.ShortcutKeys & gt; & Lt; U: ShortcutKeyCollection & gt; & Lt; U: key of the shortcut = "delete" command = "{binding path = MyViewModelProperty}" /> And lt; / U: ShortcutKeyCollection & gt; And lt; / U: Command.ShortcutKeys & gt; & Lt; / SDK: data grid & gt; The data reference is set correctly because other data bindings set on the grid are working properly I command Shortcut Key is an Dependency Property as defined in the following form:
Dependency for public static reading property shortcutkeys property = dependency property. Registrant Attached ("Shortcut Keys", Typef (Shortcutki Collection), Typef (Command), New Property Metadata (Changing Shortcuts)); ShortcutKeys changed to private static void (dependency object obj, DependencyPropertyChangedEventArgs args) {var shortcut = args.NewValueShortcutKeyCollection; If (OBJ UIElement & shortcut! = Null) UIElement as {var element = obj; Shortcuts Foric (SP => element.KeyUp + = (s, e) => sk.Command.Execute (zero)); }} Public Static Shortcuts Collection GetShortcutKeys (Dependent Object OBJE) {Returns (Shortcut Key Collection) obj.GetValue (Shortcut Keysproperty); } Public Fixed Zero SetShortcutKeys (dependency object obje, shortcut keys collection keys) {obj.SetValue (shortcutkeysproperty, keys); } I know that the property of this attachment is working properly because there is the firing of incident operators, however, command command of objects Data is not being binding. Here is the definition of the shortcut :
public class shortcutkey: dependencyobject {public static read-only dependency property keyprocity = dependency property Registration ("key", typef (key), typef (shortcutkey), tap); Public Static Read Only Dependency Property Commandpropty = Dependency Property. Controls ("command", typef (icmand), typef (shortcut key), blank); Public Key {Return (Key) Gate Value (Keyproperty); } Set {set value (keyproperty, value); }} Public Icmand Command {Received (ICMMM) Gatevalue (CommandProperty); } Set {set value (commandproperty, value); }}} Public class ShortcutKeyCollection: ObservableCollection & lt; Shortcutkey & gt; {} This property which is set in the constructure of my visual model, and its type is ICommand then why not my command Is the property data being binding? Also, have you found an effective way to debug data binding issues in Silverlight?
Edit:
At least one thing that was wrong was You must specify the source binding, since the inheritance is not inherited by the DataContact Observe. Edit: Try changing the ShortcutKey.DataContext to onShortcutKeys: instead of the framework element , which is apparently the only root class that can be applied to the binding. However, even after that change, the binding is not working properly.
Shortcut changes to private static void (dependency object Observe, Dependency Property Aventurge Args) {var Shortcuts = Arguments New Value Shortcutki Collection; If (obj framework is the element and amp shortcut! = Null) {var element = obj as FrameworkElement; Unit (shortcuts ski in shortcuts) {sk.DataContext = element.DataContext; Element.KeyUp + = (s, e) = & gt; Sk.Command.Execute (zero)); }}}
Comments
Post a Comment