Category: "Announcements [B]"
Preview Visual Studio 2015
Yesterday, I fired a Virtual Machine with Visual Studio 2015 RC. This is the best way to try out this. Unless you need to download the installation files and install them. I think it requires about an hour, firing a VM is only about 3 minutes.
I tried it for a little while, that is not bad at all. The major improvements are in mobile app development, it has a better integration with xamarin. However, you still need to download xamarin.
Refresh Datagrid in WPF
There is no such things for DataGrid.DataBinding() in Datagrid, WPF, the data grid should update itself if any items in the collection is changed. However, I found if the data source is edited by other windows, it won't refresh the data grid.
Well, you can use DataGrid.Items.Refresh(), but sometime, I got an exception about not allow editItem, something like that.
I found the best way is setting the item source to null and set item source to be bounded the collection again, like this:
Code
public void DisplayList(IList< ISchedule> lst) | |
{ | |
lstItems.ItemsSource = null; | |
lstItems.ItemsSource = lst; | |
//lstItems.Items.Refresh(); | |
} |
Error: Specified key is not a valid size for this algorithm. (TripleDES)
I built a Cryptography application by using TripleDES. But I got an error:
System.Security.Cryptography.CryptographicException: Specified key is not a valid size for this algorithm.
The key I used was in an incorrect length, it should 16 bytes length.
For example:
Code
PasswordDeriveBytes pwd = new PasswordDeriveBytes("password", salt); | |
TripleDES alg = TripleDES.Create(); | |
| |
alg.Key = pwd.GetBytes(16); | |
alg.IV = new byte[alg.BlockSize / 8];; |
WPF TextBlock Click Event
Actually, for WPF TextBlock Component, there is no click event. The best replacement is Mouse Down Event,
Like this:
Code
text1.MouseDown += text1_MouseDown; |
Adding a WPF control into a panel programmatically
The best way to design an interface for WPF is using xaml. However, in some situation, we need to change the layout in code. For example, we select a category view, we need to add a new block in a stack panel.
For example:
Code
TextBlock text1 = new TextBlock(); | |
text1.Text = grid.HeaderText; | |
LinearGradientBrush style = this.FindResource("LeftHeaderBrush") as LinearGradientBrush ; | |
text1.Background= style; | |
text1.Height = 100; | |
inactivePanels.Children.Add(text1); |