Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts

Tuesday, March 15, 2011

WPF Right-align GridViewColumn (For Arabic)

<listview.resources>

<datatemplate key="RightTemplate">

<textblock horizontalalignment="Right" textalignment="Right" text="{Binding Path=MyColumn}" />

</datatemplate>

</listview.resources>


<gridviewcolumn width="Auto" header="Grid Column Header" celltemplate="{StaticResource RightTemplate}" />

Monday, March 8, 2010

Assign datatable to combobox WPF

.XAMAL Code
ComboBox Height="23" HorizontalAlignment="Left" Margin="6,90,0,0" Name="cmbPlaceOfWork" VerticalAlignment="Top" Width="191"
(put xamal tags, < before ComboBox and /> after "191")

.XAMAL.vb Code
01-Imports System.ComponentModel

02-Private Sub FillPlaceOfWork()

Me.cmbPlaceOfWork.ItemsSource = (CType(DBRelated.GetDataTable("Select CME, FirstName As FullName From Personnel"), IListSource)).GetList()
Me.cmbPlaceOfWork.DisplayMemberPath = "FullName"
Me.cmbPlaceOfWork.SelectedValuePath = "CME"

End Sub

INFO: DBRelated.GetDataTable("Select CME, FirstName As FullName From Personnel")
The above function is from my class DBRelated and its just returning a datatable (i am using access as my backend db)

03-Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSearch.Click
MessageBox.Show(Me.cmbPlaceOfWork.SelectedValue)
End Sub

Select some value and you can get the SelectedValue by the above property of combobox.

Application/AppDirectory Path WPF

Full exe path
System.Reflection.Assembly.GetExecutingAssembly().Location

Directory from exe file executed
AppDomain.CurrentDomain.BaseDirectory

Tuesday, March 2, 2010

Change label color programmatically in WPF

Rather than System.Drawing.Color enum
use System.Windows.Media.Brushes

Me.lblDentist.Foreground = Brushes.Blue

Exit a WPF application

Application.Current.Shutdown()