Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 27 23:49

    grokys on styling

    Fix problems with setter bindin… (compare)

  • Feb 27 23:33
    Deadpikle commented #3503
  • Feb 27 23:00
    Symbai opened #3618
  • Feb 27 20:51
    kekekeks labeled #3617
  • Feb 27 20:51
    kekekeks edited #3617
  • Feb 27 20:48
    define-private-public opened #3617
  • Feb 27 18:00
    danwalmsley labeled #3585
  • Feb 27 18:00
    danwalmsley unlabeled #3585
  • Feb 27 18:00
    danwalmsley unlabeled #3613
  • Feb 27 17:59
    danwalmsley labeled #3613
  • Feb 27 15:26
    mbedded closed #3614
  • Feb 27 15:26
    mbedded commented #3614
  • Feb 27 15:26
    aguahombre commented #3608
  • Feb 27 14:31

    MarchingCube on master

    Fixed obsolete API usages. Merge branch 'master' into upda… Merge pull request #3604 from j… (compare)

  • Feb 27 14:29
    MarchingCube closed #3604
  • Feb 27 12:29
    aguahombre opened #3616
  • Feb 27 11:22
    grokys commented #3614
  • Feb 27 11:19
    grokys commented #3602
  • Feb 27 11:18
    grokys commented #3602
  • Feb 27 10:46
    kekekeks commented #3602
Nikita Tsukanov
@kekekeks
I think we aren't currently checking for dialog owner loops
Jose C Gomez
@josegomez
right that appears to be the case it allowed me to do it, not a huge deal just a heads up
if you'd like I can open an issue
Steven Kirk
@grokys
Yeah if you could open an issue that would be helpful
Jose C Gomez
@josegomez
RadioButton binding, is there a way to have 2 RadioButtons which each "change" the value of the same binding?
I can't see a Value property on the radio button
Daniel Keenan
@dfkeenan
Aww, I was hoping to change (inherit from) NumericUpDown and add a "Small Increment". Somethings are private though. So might have to copy the code and create a new one. My goal is to have a numeric textbox like in Blender: buttons either side of input; click and drag to increment/decrement; use a key modifier to use small increment; be able to do basic math.
Daniel Keenan
@dfkeenan
Why is it so hard to create paths. I tried copying the existing paths into InkSkape and rotate them 90 degrees. But kind of horrible. Any better suggestions?
Daniel Keenan
@dfkeenan
Hacks!!
<Path.RenderTransform>
  <RotateTransform Angle="90" />
</Path.RenderTransform>
Daniel Keenan
@dfkeenan
Hmm, all the math IValueConverter (WPF) I can find have the math in the parameter not as the value.
ahopper
@ahopper
they generally apply the maths to the value though
I wonder if it is possible to make something like StringFormat but MathFormat (had to work hard to write American then)
Daniel Keenan
@dfkeenan
image.png
Making some progress I guess.
Daniel Keenan
@dfkeenan
I created my own converter and tried doing Text="{TemplateBinding Text, Converter={x:Static cv:MathExpressionConverter.Instance }}". Not doing what I want though.
Daniel Keenan
@dfkeenan
Hmm, doesn't Avalonia have the equivalent of Binding.UpdateSourceTrigger?
Nikita Tsukanov
@kekekeks
Unfortunately, not
we are always using PropertyChanged policy
Daniel Keenan
@dfkeenan
Is there a way to make it so the TextBox doesn't update until you press enter? I think constantly converting a math expression with every keystroke will be trouble.
Nikita Tsukanov
@kekekeks
You can create a behavior, I guess
And bind your model there
Then you could implement a custom property update logic
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.