Quantcast
Viewing all articles
Browse latest Browse all 256

[VS2012]Some Basic questions about WPF forms

Hello
I am new to WPF (first day today) , i have nice experience with windows forms with Vb , now i am starting wpf forms with VB (I dont know much XAML yet) but i feel like we can do all with code and drag and drop on form and changing properties

Q1] I learnt about doubleanimation class , but the animation i am making is not smooth , its flickering
Code:


Private Delegate Sub Check()

Private Sub dropdown_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles dropdown.MouseLeftButtonDown

        Me.Background = New SolidColorBrush(Windows.Media.Color.FromRgb(64, 63, 63))
        Dim t As System.Threading.Thread = New System.Threading.Thread(AddressOf Resize)
        t.Start()

    End Sub

Private Sub Resize()

        If Me.Dispatcher.CheckAccess() = True Then
            If Not Me.Height = sh Then
                Dim da As New DoubleAnimation
                da.From = 30
                da.To = sh
                da.Duration = New Duration(TimeSpan.FromSeconds(0.3))
                Me.BeginAnimation(MainWindow.HeightProperty, da)
            Else
                Dim da As New DoubleAnimation
                da.From = sh
                da.To = 30
                da.Duration = New Duration(TimeSpan.FromSeconds(0.3))
                Me.BeginAnimation(MainWindow.HeightProperty, da)
            End If
        Else
            Me.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, New Check(AddressOf Me.Resize))
        End If

    End Sub

it is code i am using for resizing form with animation , but it flickers a lot , its not smooth , (it looks a bit smooth if i increase animation duration to 7sec or more) i want to fix it

Q2] Docking and align , in vb we directly have a dock property , and even align which auto aligns labels and textbox to center of form when form is resized , here i tried using margin but i don't know what will be its margins in order to keep center when form is resized (i tried using properties but its not working in my case , i maybe doing something wrong ) , when i resize the label doesn't change place and get to center
my current form XAML code is
HTML Code:

<Window x:Name="Main_Bar" x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="347.735" Width="624.676" Margin="0" Background="#01000000" Foreground="#01000000" ResizeMode="NoResize" AllowsTransparency="True" WindowStyle="None">

    <Window.OpacityMask>
        <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="#FF020202" Offset="1"/>
        </LinearGradientBrush>
    </Window.OpacityMask>
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo/>
    </Window.TaskbarItemInfo>
    <Canvas x:Name="canvas" HorizontalAlignment="Left" VerticalAlignment="Top">
        <Label x:Name="dropdown" Width="625" Height="29" Background="#FF403F3F"/>
        <DockPanel x:Name="dock1" Height="310" Width="625" HorizontalAlignment="Right">
            <Label x:Name="lbl_time" Content=" 00:00 AM" RenderTransformOrigin="0.499,0.441" VerticalAlignment="Top" Foreground="#FFFDFAFA" FontWeight="Bold" FontFamily="Nougat" FontSize="20" HorizontalContentAlignment="Center" DockPanel.Dock="Top"/>
        </DockPanel>
    </Canvas>
</Window>

Q3] What a canvas is ? , why i need canvas to put more than 2 controls at same time ?
I deleted canvas and added a label , it got added , then i tried to add a button , the label disappears , like its deleted


Q4] can i import all the libraries that i could in normal Vb .NET 4.0 windows forms ?

Q5] Can i give glass effect (Gaussian blur ) to a full transparent form ? i tried but it doesn't seem to work , idk why but i could click even in back application through my form , like form doesn't even exist

Q6] What is that Storyboard thing ? can i use same with vb code ?

Q7] And can u tell me where i can learn manipulating WPF forms through vb code , not through XAML ? or i don't have a option and need to learn XAML?


Unrelated to WPF ] Q8] How can i permanent dock my application on desktop screen , like taskbar ?


Thank You
Bianrybot

Viewing all articles
Browse latest Browse all 256

Trending Articles