Notifications
Clear all
[Closed] Adding image to the WPF control
Apr 11, 2015 12:34 pm
This is my script:
(
dotNet.loadAssembly @"WindowsFormsIntegration.dll"
global MenuRol
try(cui.UnRegisterDialogBar MenuRol)catch()
try(destroyDialog MenuRol)catch()
rollout MenuRol "" width:1000 height:23
(
dotNetControl ElementHost "Integration.ElementHost" width:MenuRol.width height:MenuRol.height pos:[0,0]
fn WPFControl Nam =
(
dotNetObject ("System.Windows.Controls."+Nam)
)
on MenuRol open do
(
Mnu = WPFControl "Menu" ; ElementHost.child = Mnu
Mnu_File = WPFControl "MenuItem" ; Mnu.items.add Mnu_File ; Mnu_File.header = "File"
M_FileLB = WPFControl "ListBox" ; Mnu_File.items.add M_FileLB
M_FileOpen = WPFControl "ListBoxItem" ; M_FileLB.items.add M_FileOpen
M_FileOpenSP = WPFControl "StackPanel" ; M_FileOpen.content = M_FileOpenSP
M_FileOpenTx = WPFControl "TextBlock" ; M_FileOpenSP.Children.add M_FileOpenTx ; M_FileOpenTx.text = "Open"
-- how I can add image here?
M_FileSave = WPFControl "ListBoxItem" ; M_FileLB.items.add M_FileSave
M_FileSaveSP = WPFControl "StackPanel" ; M_FileSave.content = M_FileSaveSP
M_FileSaveIm = WPFControl "TextBlock" ; M_FileSaveSP.Children.add M_FileSaveIm ; M_FileSaveIm.text = "Save"
)
)
createDialog MenuRol
cui.RegisterDialogBar MenuRol style:#(#cui_dock_top)
cui.DockDialogBar MenuRol #cui_dock_top
)
How I can add images to the listbox items? also I want to control its size.
2 Replies
Apr 11, 2015 12:34 pm
No replies? Let me change my question:
How we can assign a bitmap to the .source property?
Apr 11, 2015 12:34 pm
Nevermind, I found it:
Image = dotNetObject "System.Windows.Controls.Image"
ImagePath = "C:/Temp/Image.png"
ImageSource = dotnetobject "System.Windows.Media.Imaging.BitmapImage"
ImageSource.BeginInit()
ImageSource.UriSource = dotnetobject "System.uri" ImagePath
ImageSource.EndInit()
Image.Source = ImageSource