[Ironpython-users] DependencyProperty problem

Bob K. rkamarowski at yahoo.com
Tue Jul 7 18:37:24 CEST 2015


Visual Studio Community 2013
IronPython
Windows 8.1

I have a button created using xaml. In python I'm trying to set the
background using SetValue. SetValue requires the DependencyProperty and then
the value I want to set. I've been searching the net and trying different
values, but I can't find where/how to define the DependencyProptery.

<Style TargetType="Button" x:Key="ToolBarButtonStyleZ">

                <Setter Property="Background" Value="Black"/>

                <Setter Property="Foreground" Value="White"  />

                <Setter Property="HorizontalAlignment" Value="Center"/>

                <Setter Property="Height" Value="35"/>

                <Setter Property="TextBlock.FontSize" Value="20"/>

                <Setter Property="VerticalAlignment" Value="Center"/>

                <Setter Property="Width" Value="200"/>

                <Setter Property="Template">

                    <Setter.Value>

                        <ControlTemplate TargetType="Button">

                            <Border Background="{TemplateBinding
Background}">

                                <ContentPresenter
HorizontalAlignment="Center" VerticalAlignment="Center"/>

                            </Border>

                        </ControlTemplate>

                    </Setter.Value>

                </Setter>

                <Style.Triggers>

                    <Trigger Property="IsPressed" Value="True">

                        <Setter Property="Background" Value="Gray" />

                    </Trigger>

                    <Trigger Property="IsMouseOver" Value="True">

                        <Setter Property="Background" Value="Gray"/>

                    </Trigger>

                </Style.Triggers>

            </Style>

 

<Button Name="ButtonToolbarSession"

                    Click="ButtonToolbarSession_Click"

                    Content="Session"

                    Style="{DynamicResource ToolBarButtonStyleZ}">

            </Button>

  _____  

Python:
import wpf
import clr
clr.AddReference('System.Drawing')
clr.AddReference("System.Windows")
clr.AddReference("WindowsBase")
clr.AddReference("PresentationCore")
clr.AddReference("PresentationFramework")
from System.Drawing import Color
from System.Windows import Application, DependencyObject,
DependencyProperty, MessageBox, Window

class MyWindow(Window):
def init(self):
wpf.LoadComponent(self, 'Photography.xaml')

def ButtonToolbarSession_Click(self, sender, e):

   self.Background.SetValue(self.Background, Color.Gray)

  #pass

if name == 'main':

Application().Run(MyWindow())

If this is not the correct forum, could someone direct me to one?
Thank you,
Bob K.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20150707/10481782/attachment.html>


More information about the Ironpython-users mailing list