Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:11
    Deadpikle opened #3752
  • 22:06
    Gillibald commented #3697
  • 22:03
    FoggyFinder closed #3295
  • 22:03
    FoggyFinder commented #3295
  • 21:53
    Gillibald commented #3748
  • 21:52

    Gillibald on master

    Add failing test for clearing S… Delete selection if SelectedTex… SelectedText = null -> clear te… and 2 more (compare)

  • 21:52
    Gillibald closed #3748
  • 21:37
    grokys synchronize #3748
  • 21:34

    grokys on 2838-style-or

    (compare)

  • 21:34

    grokys on master

    Add failing tests for #2838. Fix comma (or) style selector. … Merge branch 'master' into fixe… and 4 more (compare)

  • 21:34
    grokys closed #3678
  • 21:34
    grokys closed #2838
  • 21:22
    grokys opened #3751
  • 21:22
    grokys review_requested #3751
  • 21:22
    grokys review_requested #3751
  • 21:19

    grokys on 497-shared-contextmenu

    Add failing tests for shared co… Allow context menus to be share… (compare)

  • 21:17
    Deadpikle synchronize #3748
  • 21:13
    ahmedflix25 commented #3697
  • 21:12
    grokys synchronize #3678
  • 21:12

    grokys on 2838-style-or

    Fix large/small scroll in Scrol… Auto-update to .sln file by VS … Add missing access modifier. and 4 more (compare)

Daniel Keenan
@dfkeenan

So I changed the TextBox.Text binding in my NumericUpDown template to {TemplateBinding Text, Converter={x:Static cv:MathExpressionConverter.Instance }, Mode=TwoWay}. And made my converter like so:

public class MathExpressionConverter : IValueConverter
{
    public static readonly MathExpressionConverter Instance = new MathExpressionConverter();

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return value;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is string input && MathExpressionParser.TryParseExpression(input, out var expression))
        {
            return expression.Compile().Invoke().ToString();
        }
        return new BindingNotification(new Exception("Invalid expression."), BindingErrorType.DataValidationError);
    }
}

And I pretty much get what I want. It does the calculation without clearing the expression and when you press enter it commits the answer and displays the result. IDK how that works.

Benedikt Stebner
@Gillibald
I think number formats can automatically be applied by the text shaping engine
Daniel Keenan
@dfkeenan
I'm not sure if it's because of avalonia or visual studio. But everytime a xaml file is added it makes a bit of a mess of things in the csproj file.
Daniel Keenan
@dfkeenan
Is there a way to tell if a property is bound?
Daniel Keenan
@dfkeenan
Hmm, you can't use WindowIcon as image source?
Daniel Keenan
@dfkeenan
Is there a psuedo for window being active?
OpenMan
@openmandev

@grokys

@openmandev sounds like a bug. could you open an issue with a minimal repro and i'll try to fix it

AvaloniaUI/Avalonia#3468

Daniel Keenan
@dfkeenan
I tried this but get selector errors.
<Style Selector="Window.Metro[IsActive=true] /template/ #Window_Border">
  <Setter Property="BorderBrush" Value="{DynamicResource ThemeAccentBrush}" />
</Style>
Daniel Keenan
@dfkeenan
image.png
I'm trying to make a WindowTitleBar control. To make it easy to make custom chrome window
Daniel Keenan
@dfkeenan
Well you can move the window. :D
Is there a better way to get the window than VisualRoot is Window window?
Daniel Keenan
@dfkeenan
This is probably the wrong way todo things:
protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
{
    base.OnTemplateApplied(e);

    if (VisualRoot is Window window)
    {
        var min = e.NameScope.Find<Button>("PART_MinimizeButton");
        min.Click += (s, e) => window.WindowState = WindowState.Minimized;

        var max = e.NameScope.Find<Button>("PART_MaximizeButton");
        max.Click += (s, e) => window.WindowState = WindowState.Maximized;

        var res = e.NameScope.Find<Button>("PART_RestoreButton");
        res.Click += (s, e) => window.WindowState = WindowState.Normal;

        var close = e.NameScope.Find<Button>("PART_CloseButton");
        close.Click += (s, e) => window.Close();

        max.IsVisible = window.WindowState != WindowState.Maximized; 
        res.IsVisible = window.WindowState == WindowState.Maximized;

        //TODO: How to hand window.IsActive Changed
    }
}

protected override void OnPointerPressed(PointerPressedEventArgs e)
{
    base.OnPointerPressed(e);
    if (VisualRoot is Window window)
    {
        window.BeginMoveDrag(e);
    }
}
I thought I could use window.GetPropertyChangedObservable(Window.IsActiveProperty) somehow. I can't find any example of it in the code though.
Daniel Keenan
@dfkeenan

Wrong property to start with. :D
I tried:

window.GetPropertyChangedObservable(Window.WindowStateProperty)
      .AddClassHandler((System.Action<WindowTitleBar, AvaloniaPropertyChangedEventArgs>)((t, e) =>
      {
          WindowState newValue = (WindowState)e.NewValue;
          max.IsVisible = newValue != WindowState.Maximized;
          res.IsVisible = newValue == WindowState.Maximized;
      }));

but that doesn't do anything.

Daniel Keenan
@dfkeenan
:O If you set HasSystemDecorations to false to hide the titlebar you also loose the ability to resize. D:
Nikita Tsukanov
@kekekeks
You are expected to implement your own resize grips
See DecoratedWindow in ControlCatalog
Daniel Keenan
@dfkeenan
I have created a custom WindowBorder control that mostly works. But sometimes when resizing the cursor changes back to the default.
image.png
Nikita Tsukanov
@kekekeks
Also note, that custom border is something undesirable on non-windows platforms
Daniel Keenan
@dfkeenan
max.IsVisible = window.WindowState != WindowState.Maximized;
res.IsVisible = window.WindowState == WindowState.Maximized;

var windowStateChanged = window.GetPropertyChangedObservable(Window.WindowStateProperty)
    .Select(e => (WindowState)e.NewValue);

max.Bind(Button.IsVisibleProperty, windowStateChanged.Select(ws => ws != WindowState.Maximized));
res.Bind(Button.IsVisibleProperty, windowStateChanged.Select(ws => ws == WindowState.Maximized));
Seems to work. :D
Daniel Keenan
@dfkeenan
Does anyone know what this thing in my csproj is?
  <ItemGroup>
    <Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
  </ItemGroup>
ahopper
@ahopper
t4 templates I think
Daniel Keenan
@dfkeenan
I do have one of those.
ahopper
@ahopper
how did it get there, I have it in some of mine but only when I add it
Daniel Keenan
@dfkeenan
I created the t4 template. I just don't remember seeing that service tag before.
ahopper
@ahopper
I guess vs adds it, I must have got into the habit of adding it myself.
Daniel Keenan
@dfkeenan
I ended up creating a WindowIconToBitmapConverter. I think my window is looking pretty good now.
image.png
Daniel Keenan
@dfkeenan
Not sure if I should embed a C# editor (RoslynPad) or just leave it watching the .csx file and continue to use VSCode.
ahopper
@ahopper
I ended up creating a WindowIconToBitmapConverter.
I had been thinking of doing the opposite and creating a vector drawing to .ico converter for my iconpacks app
Daniel Keenan
@dfkeenan
The Window.Icon property is of type WindowIcon and you can't seem to use it as an Image.Source.
Jose C Gomez
@josegomez
Hey guys sorry to ask again but any pointers on using bindings with radio buttons? I can't figure out how to bind several buttons to a single property in the model and have each radio change the value
A
Steven Kirk
@grokys
@josegomez binding the radio buttons to an enum? we don't have any particular way of doing this, you should handle it the same as WPF, e.g. https://stackoverflow.com/questions/397556/how-to-bind-radiobuttons-to-an-enum

@dfkeenan

I'm not sure if it's because of avalonia or visual studio. But everytime a xaml file is added it makes a bit of a mess of things in the csproj file.

yeah, this is VS :/ we should probably open an issue on the VS project system because it's really annoying

Is there a way to tell if a property is bound?

not bound as such but you can call AvaloniaObject.IsSet() to see if the property is set. there's no API that makes a distinction between a set and bound value though

Jose C Gomez
@josegomez
@grokys Not necessarily to an enum I just want the value of the radios to change the same field in the model
ir Radio1 bound to field x If checked sets x to "hi"
Radie2 bound to field x also if checked sets x to "bye"
I’ll check out the wpf suggestion
Splitwirez
@Splitwirez
...is it possible to have a selector check if a property's value is null (or non-null, for that matter)? And if so, how would one do this?
Daniel Keenan
@dfkeenan
Is there a "platform" style selector?
lorean-devries
@lorean-devries
what themes does avalonia support ?
lorean-devries
@lorean-devries
I have a WPF app built with Material Design which I wish to convert to a Avalonia UI powered app ?
Nikita Tsukanov
@kekekeks
there was an attempt to make material-like style
lorean-devries
@lorean-devries
cool beans thank you will have a look at it now
Omid Mafakher
@OmidID

I have problem with Linux Framebuffer that the device we have it's have inverted touch by X and Y and this is the configuration of xorg conf

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "InvertX" "True"
        Option "InvertY" "True"
EndSection

In case of using framebuffer the libinput is not using xorg config anymore and it's will start independ of X server.
I found out there is a function exists in libinput that can fix this problem.
https://wayland.freedesktop.org/libinput/doc/latest/api/group__config.html#ga09a798f58cc601edd2797780096e9804
How can I calibrate the device from the code using this function? The main problem is how can I have the struct libinput_device * device variable?