Determining the Enter key is pressed in a TextBox
A straight forward approach for this in a textbox is private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Debug.WriteLine(“Enter”); } }
A straight forward approach for this in a textbox is private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Debug.WriteLine(“Enter”); } }
I have received this error message for another (non-GAC, custom) assembly. In my case, the situation was as follows: assembly X contains class A assembly Y contains class B, which inherits from A assembly Z contains a data template for class B Y referenced X, Z referenced Y. The error message was pointing to the … Read more
You should check, in every folder of your project, for missing files or wrong references. You can get this problem just with a single missing image, if its Build Action property is set to Content or similar… Check your files and then Rebuild your project!
I definitely think you should use the MVVM pattern for Silverlight applications – and one of the benefits of the pattern is that you can actually make your application really blendable through some simple techniques. I often refer to “blendability” as “design for designability” – that you use certain techniques to make sure your application … Read more
This helped me understand the reasoning: The main difference is, that the value of a normal .NET property is read directly from a private member in your class, whereas the value of a DependencyProperty is resolved dynamically when calling the GetValue() method that is inherited from DependencyObject. When you set a value of a dependency … Read more
The ViewModelLocator class helps keep a centralized store for your viewmodels. You can use this class to help manage new versions and clean up old ones. I always reference my viewmodel from view via the locator, so I always have code I can run to manage these things. You could try that. As well, I … Read more
Try this: BitmapImage image = new BitmapImage(new Uri(“/MyProject;component/Images/down.png”, UriKind.Relative));
Its a very slim distinction, which I can explain best by comparing MVC in ASP.NET and MVVM in WPF. In ASP.NET MVC the request comes in from the web server and is handled directly by the Controller. The Controller determines the appropriate View and populates it with Models. The Controller then releases these instances to … Read more
You can work with normal property without Dependency property if you create a Base class for your Page. public class BaseWindow : Window { public string MyProperty { get; set; } } <local:BaseWindow x:Class=”BaseWindowSample.Window1″ x:Name=”winImp” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local=”clr-namespace:BaseWindowSample” MyProperty=”myproperty value” Title=”Window1″ Height=”300″ Width=”300″> </local:BaseWindow> And it works even though MyProperty is not a Dependency or … Read more
This is kind of an old question, but I figured I’d give my answer since I found this thread by Googling for the exact same problem. In my case, I’d copied some sample XAML from the web to get started with Silverlight Toolkit 4. That sample XAML contained a simple button with a click event … Read more