Accessing the Global variables in one Window/Page from another in WPF.
This was the first problem I found in my migration from WinForms to WPF.
In WinForms, what we usually do is
frmFormName.GlobalVar1=value
In WPF, this fails miserably.
The workaround is
Dim VarToChange as Integer
Public Property VarNameDesc as Integer
Get
Return VarToChange
End Get
Set(ByVal value As Integer)
VarToChange=value
End Set
Now, you can access/change it from another window by using
MainWindow.VarNameDesc
.
Using a UserControl UC1 from your existing project
Adding a custom control or UserControl to the Toolbox has the following limitations.
Works only for custom controls defined outside the current project.
Does not update correctly when you change the solution configuration from Debug to Release, or from Release to Debug. This is because the reference is not a project reference, but is for the assembly on disk instead. If the control is part of the current solution, when you change from Debug to Release, your project continues to reference the Debug version of the control.
In addition, if design-time metadata is applied to the custom control and this metadata specifies that the ToolboxBrowsableAttribute is set to false, the control does not appear in the Toolbox.
Source :
http://msdn.microsoft.com/en-us/library/bb514128.aspx[
^]
After some meddling with the XAML File, the workaround was adding this to the Window tag :
xmlns:my="clr-namespace:ProjectName"
Actually, a dropdown will let you choose.
Then, I found this link (Wish I had seen it before!) :
http://msdn.microsoft.com/en-us/library/bb514546.aspx[
^].
The Obsolete OuterGlow BitmapEffect
Visual Studio warned me that
BitmapEffect
became Obsolete. I wanted the OuterGlow effect actually. The
DropShadowEffect
with
ShadowDepth
set to 0 did the job.
Dim og As New DropShadowEffect
og.ShadowDepth = 0
og.BlurRadius = 11
og.Color = Colors.Gold
btnDemo.Effect = og
Using Windows Forms Controls
I actually needed a DateTimePicker (WPF in .NET 3.0). Since it is introduced only in later versions, I used the WindowsFormsHost control.
<windowsformshost name="wfh">
<wf:datetimepicker visible="True" name="dtFinally" xmlns:wf="#unknown">
</wf:datetimepicker></windowsformshost>
Typing
<wf:
will automatically show the list.
Make sure to include the following in the Window tag :
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"