Beginners Example

This forum is meant for examples of X# code.

User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Joe,
I will do that, of course.
WPF is even easier to do (for me) as most of my pure X# programming is done in WPF (and XIDE).
My WPF windows are all done in pure code, and that helps me be more flexible.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Joe,
here it is:
WPFDBF.zip
(3.19 KiB) Downloaded 138 times
It seems even easier than the Windows Forms example.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Beginners Example

Post by FFF »

Very nice, Wolfgang.
Me being a WPF-noob - is there an easy way to change the font used in the datagrid?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Karl,
really hard <g>:

Code: Select all

_oDataGrid:FontFamily	:= FontFamily{ "Courier New" }
_oDataGrid:FontSize		:= 20
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Beginners Example

Post by FFF »

Blush...
(But, by way of excuse, i had looked in the api browser, there's no entry regarding font in DataGrid's properties...)

While blushing ;-) , Datagrid has a backround property, but that's only the little rectangles fencing the scrollbar.
Probably, i need oDataGrid:CellStyle := Style{ } ? But i don't get, what/which "type" the style constructor wants...
THX!
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Karl,
unfortunately it is not that easy. This is code from my own class library:

Code: Select all

oHeaderStyle := Style{ TypeOf( System.Windows.Controls.Primitives.DataGridColumnHeader ) }
oHeaderStyle:Setters:Add( Setter{ System.Windows.Controls.Primitives.DataGridColumnHeader.BackgroundProperty, MVVMControlSettings.DataGridHeaderBackground } )
oHeaderStyle:Setters:Add( Setter{ System.Windows.Controls.Primitives.DataGridColumnHeader.SeparatorVisibilityProperty, Visibility.Visible } )
oHeaderStyle:Setters:Add( Setter{ System.Windows.Controls.Primitives.DataGridColumnHeader.SeparatorBrushProperty, MVVMControlSettings.DataGridVerticalGridLinesBrush } )
oHeaderStyle:Setters:Add( Setter{ System.Windows.Controls.Primitives.DataGridColumnHeader.PaddingProperty, MVVMControlSettings.DataGridHeaderPadding } )
self:ColumnHeaderStyle := oHeaderStyle
oCellStyle := Style{ TypeOf( System.Windows.Controls.DataGridCell ) }
oCellStyle:Setters:Add( Setter{ System.Windows.Controls.DataGridCell.PaddingProperty, MVVMControlSettings.DataGridCellPadding } )
self:CellStyle := oCellStyle
Sometimes it is hard to work without XAML.....
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Beginners Example

Post by FFF »

Argh...
I think i sort of understand this, so to play further, could you solve "MVVMControlSettings"? Probably a Using missing, but as the apibrowser knows nothing about this term, so what to add?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Karl,
that is my static settings class - I have copied this code from there.

Code: Select all

MVVMControlSettings.DataGridHeaderPadding := System.Windows.Thickness{ 5, 5, 5, 5 }
MVVMControlSettings.DataGridCellPadding := System.Windows.Thickness{ 6, 6, 6, 6 }  // geht aktuell nicht
MVVMControlSettings.DataGridAlternatingRowBackground := System.Windows.Media.SolidColorBrush{ System.Windows.Media.Colors.Gainsboro }
MVVMControlSettings.DataGridVerticalGridLinesBrush := System.Windows.Media.SolidColorBrush{ System.Windows.Media.Color.FromRgb( 170,170,170 ) }
MVVMControlSettings.DataGridHeaderBackground := System.Windows.Media.SolidColorBrush{ System.Windows.Media.Color.FromRgb( 238, 238, 238 ) }
MVVMControlSettings.DataGridRowHeight := 20
These are the defaults for all my applications, but are settable on an application level.
Normally, you use stylesheets for this - that is easier.
But since I don't select always the easiest way, but the way that seems me more flexible, sometimes I have to do strange things.

But nevertheless, for some styles I do add a XAML stylesheet as resource into my WPF applications.
ServerMan_Ressources.png
ServerMan_Ressources.png (5.49 KiB) Viewed 1669 times
Maybe I should publish a full featured WPF application as sample.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1580
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Beginners Example

Post by FFF »

Hi Wolfgang,
thx very much, now it works.

Code: Select all

Maybe I should publish a full featured WPF application as sample
That surely would be helpfull - best including access to PG ;-)
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Beginners Example

Post by wriedmann »

Hi Karl,
PostgreSQL access is standard in my newer applications whenever I have the choice:
ServerMan_Dependencies.png
ServerMan_Dependencies.png (11.04 KiB) Viewed 1668 times
The main problem is that I have several different libraries in my framework, for different GUI choices (WPF, Windows Forms, Console) and for different database backends (DBF, ADS, Oracle, MS SQL Server, MySQL, PostgreSQL, SQLite), and therefore I have to combine a lot of code into the same application/lib to not to have to share my entire framework.
What you see is one WPF application with only PostgreSQL access, but I have also applications that are accessing 3 or 4 different database backends.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply