Wednesday, January 10, 2007

WPF ComboBox automatic onchange ToolTip in XAML only

Is dead simple as this (XAML):

<ComboBox
...
    ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Text}"
...

Enjoy!
J.

How to make simple (Free!) Grid in WPF with XAML from DataSet or DataTable

This is just a concept you can start with to make your own Grid in XAML.

XAML Part:

<ListBox x:Name="tgData"
Grid.Row="1"
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Path=TableOne}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox
Style="{DynamicResource HorizontalList}"
ItemsSource="{Binding Path=Row.ItemArray}"
>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="100" Text="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

XAML Style for Horizontal List for columns:
<Style x:Key="HorizontalList" TargetType="{x:Type ListBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal" Panel.IsItemsHost= "True"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Code Behind (VB.Net):
Dim sConnectionString As String = "Data Source=Kelner;Database=Northwind;Integrated Security=SSPI;"
Dim sQueryString As String = "SELECT * FROM dbo.Customers"

Dim dsCustomer As New DataSet("CustomerData")
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(sConnectionString)
Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(sQueryString, conn)

Dim customers As DataSet = New DataSet
adapter.Fill(dsCustomer, "TableOne")
tgData.DataContext = dsCustomer

Enjoy!
J.

Hello World!

My first post I guess!

Hi there. I always wanted to put a place on "the web" where can share some nice trick encountered in my daily work on various software technologies.

So here it is!

Enjoy!
J.