Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ruben W.
    @rubenwe
    Hi. Is there any way to put the scss code in an external file and get it to work at design time?
    I would love to have at least some kind of syntax highlighting without copying around code all the time :worried:
    Ruben W.
    @rubenwe
    Okay.. I found a workaround that is okay for now
    But I would still love to hear if there is an "official" way to do this :)
    David Rettenbacher
    @warappa

    Willkommen @rubenwe !

    Unfortunately I myself have not found a way yet, as the designer needs to be aware of a change. The designer automatically detects changes in resources, but to detect file-changes I would have to develop a vs-extension to notify the designer that something has changed...

    What workaround are you using?

    Ruben W.
    @rubenwe

    I bound to a static property of a class and read it from an .scss file in the getter.
    That doesn't deal with the update problem you mentioned - but at least I got it working without copying between scss and resource files.

    I had to disable XamlCSS later on, because I ran into problems where a ControlTemplate would no longer be applied to a nested ChildControl.

    I'm quite new to WPF so I'm sorry I can't be more help and point you to what exactly went wrong there.
    But I decided to leave styling by the wayside for now.
    The learning curve is steep enough as it is :smile:
    Ruben W.
    @rubenwe

    Hey David

    I'm somewhat over the initial WPF shock and wanted to give XamlCSS another try.
    I couldn't find any information on how XamlCss deals with styles that are already applied in XAML.

    I have some elements that are already styled in XAML.
    When I apply something like * {Background: #ffffff} all previously applied styles seem to get discarded.
    If that is "by Design" it's okay.

    I guess I could just assign classes to the elements and reapply the styles that way.
    Just curious how this is supposed to work :smiley:

    David Rettenbacher
    @warappa

    Hi Ruben,

    you're right, it should not be discarded. Actually preserving already applied styles ("initial styles") is not supported in the current release 2.1, but is already in the current master branch!

    In near future initial styles are treated as every other matching style. But I think values from dynamic styles would win over values defined in the initial style as dynamic styles > static styles, but I'm not 100% sure right now :smile:
    Although possible, it's generally better to not use "" as it has performance implications (styles need to be generated for all* elements!). So working with classes is preferred :)

    However, if you want to try the new version, check out the current master branch, compile it and copy the DLLs to your "packages/XamlCSS/" directories, then rebuild. This should be enough to use the new development-version.

    Thank you for giving XamlCSS another try :+1:

    Ruben W.
    @rubenwe

    Hey David - thanks for the answer. I'll pull the DLLs right over then :D.
    I cloned the project already to have a look at some of the code.

    The star selector was just and easy example.
    Thank you for developing such a cool tool!

    David Rettenbacher
    @warappa
    Thanks, you're welcome!
    biagio roberti
    @biagioroberti_twitter
    Hi all, I'm exploring your library. For first, great job!
    I have a lot of questions, I will try to not bother you
    does your library support the background-image css property?
    biagio roberti
    @biagioroberti_twitter
    2) can i download at runtime a css file or I have to use css file as embedded resource?
    David Rettenbacher
    @warappa

    Hi @biagioroberti_twitter
    Thanks for exploring!

    background-image is not available, but: XamlCSS maps directly to the bindable properties of the platform, i.e. BackgroundColor in Xamarin.Forms or Background in WPF.
    In essence: all you can write in Xaml within attributes quotes, you can use in XamlCSS css files :smile:

    So if you would like to set an image, you would use a MarkupExtension.
    Here is an example of such a MarkupExtension for WPF:

    public class UrlBrushExtension : MarkupExtension
        {
            public UrlBrushExtension()
            {
            }
    
            public UrlBrushExtension(object value)
            {
                this.Value = value;
            }
    
            [ConstructorArgument("value")]
            public object Value { get; set; }
    
            public IValueConverter Converter { get; set; }
    
            public override object ProvideValue(IServiceProvider serviceProvider)
            {
                try
                {
                    var bitmap = new BitmapImage(new Uri((string)Value), new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable));
                    return new ImageBrush(bitmap);
                }
                catch
                {
                }
    
                return null;
            }
        }

    To use it in css:

    @namespace local "clr-namespace:MyApp.MarkupExtensions;assembly=MyApp";
    .some-element {
        Background: "{ local:UrlBrush https://raw.githubusercontent.com/warappa/XamlCSS/master/Content/Logo.jpg }";
    }

    For your 2nd question:
    Out of the box you load css from:

    • EmbeddedResource
    • Filesystem
    • Application.Resources
      Web is currently not supported (but you could load it yourself and initialize a StyleSheet with the css-string).
      But the preferred way is to add a stylesheet to your application's ResourceDictionary and applying it to your MainWindow (WPF) or the MainPage (Xamarin.Forms, UWP). This gives you live updating out of the box.
      For an example see https://github.com/warappa/XamlCSS-WPF-Samples
    Emanuele Leoni
    @emanueleleoni
    Hi, I would like to use XAMLCss for my UWP app
    I have different pages and I would like to use one stylesheet for all because the pages are similar
    So which is the best way to proceed?
    Create a stylesheet in Resource and use it in all the pages?
    Can you help me?
    MartinTichovsky
    @MartinTichovsky
    Hello, is possible to make radius at border? Something like CornerRadius? Thank you!
    Emanuele Leoni
    @emanueleleoni
    Hi @MartinTichovsky , on which element do you want to put the corner radius?
    Pascal Weyprecht
    @fx-world
    Hi, I want to style the cells of a xceed datagrid, but nothing happens. The styles of the other elements works fine, but nothing happens with the datacells.