golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Padding between buttons

20 Sep 2013, 20:48

I am programmatically adding buttons to a Stackpanel.All is well but there are spaces between
buttons as shown in the image below.
Image

I've tried using SnaptoDevicePixels instead of UseLayoutRounding property at GUIRoot after a Google search as a remedy to the problem but it seem Noesis does not respect to the property.

Also how can I set dependency properties in unity script? I am guessing it's done with SetValue() but I was unable to use it for SnaptoDevicePixels property. Should I define it myself? will it work in that case?
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Padding between buttons

21 Sep 2013, 02:10

Hi, I will try to explain what is happening.

The visual aspect of a control is determined by its Template. The buttons in your attached image are using our default style, which is designed to have a space around the button for the focus border (just click on a button and you will see a blue border around the button indicating which control has the focus).

You can modify that default appearance by defining your own ControlTemplate:
<ControlTemplate x:Key="MyButtonTemplate" TargetType="{x:Type ButtonBase}">
    <Grid UseLayoutRounding="True">
        <Border x:Name="Bg"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            CornerRadius="1"/>
        <Grid Margin="{TemplateBinding BorderThickness}">
            <ContentPresenter
                RecognizesAccessKey="True"
                Margin="{TemplateBinding Padding}"
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                UseLayoutRounding="{TemplateBinding UseLayoutRounding}"/>
        </Grid>
    </Grid>
    <ControlTemplate.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter TargetName="Bg" Property="Background" Value="Yellow"/>
        </Trigger>
        <Trigger Property="IsPressed" Value="True">
            <Setter TargetName="Bg" Property="Background" Value="Gold"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
Then you can apply that template to any button:
<Button Template="{StaticResource MyButtonTemplate}" Content="Button"/>
About SnapsToDevicePixels, we didn't implement it, in favor of UseLayoutRounding because of performance reasons.
 
golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Re: Padding between buttons

21 Sep 2013, 10:47

alright, thank you. Also added a bug to mantis tracker about noesis crashing seeing it was empty I was not sure whether you are checking it.
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Padding between buttons

21 Sep 2013, 17:58

Bug tracker is the appropriate place to post bugs.
And you see it empty because visibility is limited to only your own reported bugs.

;)
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Padding between buttons

21 Sep 2013, 18:12

Also how can I set dependency properties in unity script? I am guessing it's done with SetValue() but I was unable to use it for SnaptoDevicePixels property. Should I define it myself? will it work in that case?
All dependency properties are wrapped with the corresponding Getter and Setter functions. For example, to set the Text dependency property in a TextBlock, you can use the SetText function:
NoesisGUIPanel gui = GetComponent<NoesisGUIPanel>();
FrameworkElement root = gui.GetRoot<FrameworkElement>();
TextBlock tb = root.FindName<TextBlock>("tb");
tb.SetText("Some text");
 
golgepapaz
Topic Author
Posts: 43
Joined: 01 Aug 2013, 01:59

Re: Padding between buttons

21 Sep 2013, 19:00

All dependency properties are wrapped with the corresponding Getter and Setter functions. For example, to set the Text dependency property in a TextBlock, you can use the SetText function:
NoesisGUIPanel gui = GetComponent<NoesisGUIPanel>();
FrameworkElement root = gui.GetRoot<FrameworkElement>();
TextBlock tb = root.FindName<TextBlock>("tb");
tb.SetText("Some text");
So if I don't see it in the intellisense that means it's not implemented is that right?

As for the mantis, you could at the very least make user issues visible (if that's at all possible) this would prevent duplicate entries and help refining bugs.Surely you can use another tracker for your own internal use in any case.
 
User avatar
jsantos
Site Admin
Posts: 2905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Padding between buttons

22 Sep 2013, 01:41

So if I don't see it in the intellisense that means it's not implemented is that right?
Yes, probably. But if you miss anything just tell us.
As for the mantis, you could at the very least make user issues visible (if that's at all possible) this would prevent duplicate entries and help refining bugs.Surely you can use another tracker for your own internal use in any case.
Yes, we have our own internal tracker (with hundreds of tickets). The one found at bugs.noesisengine.com is for clients. We made it private on purpose because many times we need resources (scenes, xamls) to track the bug and we think that data must remain private, not visible for the rest of the users.

Who is online

Users browsing this forum: No registered users and 1 guest