Alex141 / CalcBinding

Advanced WPF Binding which supports expressions in Path property and other features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use Static properties

fmonroe opened this issue · comments

Here is what I have:

<Window x:Class="MySuperApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MySuperApp"
        mc:Ignorable="d"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        d:DataContext="{d:DesignInstance {x:Type dvm:DesignMainWindowViewModel}, IsDesignTimeCreatable=True}"
        xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
        Title="{Binding Title}"
        x:Name="this_" d:DesignWidth="1600" d:DesignHeight="900">

    <Window.Resources>

        <sys:Double x:Key="IconHeigh">55</sys:Double>
        <sys:Double x:Key="IconWidth">55</sys:Double>
...
    </Window.Resources>

and then :
<Path Stretch="Uniform" Fill="Black" Height="{c:Binding 'local:IconHeigh - 10'}" Data="M15,... ,2,0z" />
The binding expression is wrong - I can't figure out what it should be. Can you help please?

For static properties syntax see:
See https://github.com/Alex141/CalcBinding#2-static-properties
Form of static property: namespace:Class.Property, e.g. 'local:Icon.IconHeigh - 10'

In your xaml you want to use not static property but StaticResource, which is not supported, sorry