Hi,
I’m writing a Client Plugin with WPF C#. My problem is that when the theme is applied, the component’s graphic change. ES:
I use button with image inside and no text.
<Button IsEnabled="False" Grid.Column="1" Grid.Row="0" Name="cmdPlateDelete" Click="cmdPlateDelete\_Click" Height="40" >
<Image Source="/IPViewLPP;component/Resources/021000-recycle-bin.png" Margin="5,5,5,5"></Image>
</Button>
In the VS designer the image is centered inside the Button, but when i see it on milestone client the image is shifted on the right.
How i can set the image centered like on the designer ?
I’ve used also the HorizontalAlignment and VerticalAlignment, but the problem persist.
thanks’
Best regards
Gian-Luca
Can you make a minimal implementation plugin and share the source code so that I might reproduce and debug this?
Hi ,
i’ve used a project from your SDK using Wpf and adding button with image is all ok.
My problem is when i open another Wpf windows but in order to have the possibility to create a Wpf windows you have to edit the project adding
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
under the first PropertyGroup xml tag and reload the solution.
doing so you can create a wpf windows and call it from dll code, but if you put the same button with picture, he image is shifted. i’ll attach an example: if you click the button at the botton the windows is opened.
best regard’s
Gian-Luca
in the new windows the milestone theme is applied automatically
Now i’ve do another test. If you modify the test.xaml in this manner
<Window x:Class=“SCTheme.Client.Test”
xmlns="[http://schemas.microsoft.com/winfx/2006/xaml/presentation](http://schemas.microsoft.com/winfx/2006/xaml/presentation)"
xmlns:x="[http://schemas.microsoft.com/winfx/2006/xaml](http://schemas.microsoft.com/winfx/2006/xaml)"
xmlns:d="[http://schemas.microsoft.com/expression/blend/2008](http://schemas.microsoft.com/expression/blend/2008)"
xmlns:mc="[http://schemas.openxmlformats.org/markup-compatibility/2006](http://schemas.openxmlformats.org/markup-compatibility/2006)"
xmlns:local="clr-namespace:SCTheme.Client"
mc:Ignorable="d"
Title="Test" Height="450" Width="800"
Loaded="Window\_Loaded"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48"/>
<ColumnDefinition Width="\*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="\*"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0">
<Image Source="/SCTheme;component/Resources/006000-floppy-disk.png" Margin="5,5,5,5"></Image>
</Button>
<Button Grid.Column="1" Grid.Row="0">
<Image Source="/SCTheme;component/Resources/006000-floppy-disk.png" Margin="5,5,5,5"></Image>
</Button>
you can see that the first button col=0 row=0 the image is shifted, but the second button col=0 row=1 the image is centered. So the problem is in wpf windows when the button have a fixed size in grid
Gian-Luca
I’ve found the solution:
<Window x:Class=“SCTheme.Client.Test”
xmlns="[http://schemas.microsoft.com/winfx/2006/xaml/presentation](http://schemas.microsoft.com/winfx/2006/xaml/presentation)"
xmlns:x="[http://schemas.microsoft.com/winfx/2006/xaml](http://schemas.microsoft.com/winfx/2006/xaml)"
xmlns:d="[http://schemas.microsoft.com/expression/blend/2008](http://schemas.microsoft.com/expression/blend/2008)"
xmlns:mc="[http://schemas.openxmlformats.org/markup-compatibility/2006](http://schemas.openxmlformats.org/markup-compatibility/2006)"
xmlns:local="clr-namespace:SCTheme.Client"
mc:Ignorable="d"
Title="Test" Height="450" Width="800"
Loaded="Window\_Loaded"
>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48"/>
<ColumnDefinition Width="\*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
<RowDefinition Height="\*"/>
</Grid.RowDefinitions>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="48"/>
</Grid.RowDefinitions>
<Button Grid.Column="0" Grid.Row="0" Width="40" Height="40">
<Image Source="/SCTheme;component/Resources/006000-floppy-disk.png" Margin="5,5,5,5"></Image>
</Button>
</Grid>
<Button Grid.Column="1" Grid.Row="0" Width="40" Height="40">
<Image Source="/SCTheme;component/Resources/006000-floppy-disk.png" Margin="5,5,5,5"></Image>
</Button>
the trik’s is to encapsule the first button in a grid with the column Width set to Auto and center the content. So the image is not centered if is specified the column’s Width so if i have to put the button in a grid with specific dimension, i’ve to create a inner grid with Auto Width.
it’s possible to simplify this ? if i use the windows outside milestone it’s all ok without a second grid.
thank’s
Gian-Luca
I played with the sample.
To me it works directly. However the cause for the bad effects is something you picked up from the original sample, and I would like to change the sample for future versions.
In the sample you have a Width=“1000” for the ViewItemWpfUserControl, this means that the user control does not scale to the space for the view item unless you expand the Smart Client very much, please remove Width=“1000”, I think you will see the expected behavior then.
Hi,
thank’s for your answer, but for my production MIP i’m started from the old plugin.
If you look at my code, the problem is in the popup windows. Milestone client go on override somewhere and shift to the right the image. the problem is not on the plugin, but on the pop up windows like you can see on the example clicking at the bottom’s .
best regard’s
Gian-Luca