Fortunately, this can be worked around in the same way as in my previous post:
<Window.Resources>
<my:DataResource x:Key="cp" BindingTarget="{Binding MyCommandParameter}"/>
</Window.Resources>
<TextBox>
<TextBox.InputBindings>
<MouseBinding
Command="ApplicationCommands.Open"
MouseAction="LeftDoubleClick">
<MouseBinding.CommandParameter>
<my:DataResourceBinding DataResource="{StaticResource cp}"/>
</MouseBinding.CommandParameter>
</MouseBinding>
</TextBox.InputBindings>
</TextBox>
DataResource.cs
Download sample app with source code
4 comments:
What previous post? When you comment like this, it is customary to give a link to the post you are refering to.
Als, what does "my:DataResource" have to do with anything? I got this far:
and then added the KeyBinding to my textbox:
but this obviously isn't the only thing that needs to be done, since the my:DataResources is failing. Why does your example bind anything that you don't give code for? How do you bind something on the page you are working with?
Try this again:
<Window.Resources
my:DataResource x:Key="kd" BindingTarget="{Binding Text,ElementName=testTextBox}"/>
</Window.Resources>
<TextBox x:Name="testTextBox">
<TextBox.InputBindings>
<KeyBinding Key="Enter"
Command="{StaticResource cc}">
<KeyBinding.CommandParameter>
<my:DataResourceBinding DataResource="{StaticResource kd}"/>
</KeyBinding.CommandParameter>
</KeyBinding>
</TextBox.InputBindings>
</TextBox>
The sample app works fine for me!
Post a Comment