[IronPython] Silverlight DataBinding Not Working

Lukas Cenovsky cenovsky at bakalari.cz
Thu Dec 31 01:37:03 PST 2009


I overlooked you are doing ElementBinding.

It seems it does not work in IronPython - the Slider (element you are 
binding to) probably does not fire PropertyChanged event. I would blame 
some magic with codebehind files :-)

In this case, the slider is updated when the text box changes its value:
<Slider x:Name="sliderFontSize" Margin="3" Minimum="1" Maximum="40" 
Value="8" />
<TextBox x:Name="textboxFontSize" Text="{Binding 
ElementName=sliderFontSize, Path=Value, Mode=TwoWay}"/>

In this case, the text box is updated when the slider changes its value:
<Slider x:Name="sliderFontSize" Margin="3" Minimum="1" Maximum="40" 
Value="{Binding ElementName=textboxFontSize, Path=Text, Mode=TwoWay}" />
<TextBox x:Name="textboxFontSize" Text="5"/>

Finally this works but it not much usable:
<Slider x:Name="sliderFontSize" Margin="3" Minimum="1" Maximum="40" 
Value="{Binding ElementName=textboxFontSize, Path=Text, Mode=TwoWay}" />
<TextBox x:Name="textboxFontSize" Text="{Binding 
ElementName=sliderFontSize, Path=Value, Mode=TwoWay}"/>

--
-- Lukáš

Shyam Gopale wrote:
> But, I am just doing binding between elements. Is this still required. 
> If you see my XAML I am just binding the value of a slider to the 
> fontsize of a textblock. I am not sure if the Ironpython code hits 
> that path.
>  
> Thanks,
> Shyam
>
> On Wed, Dec 30, 2009 at 10:02 PM, Lukas Cenovsky <cenovsky at bakalari.cz 
> <mailto:cenovsky at bakalari.cz>> wrote:
>
>     Shyam Gopale wrote:
>
>         Hi,
>         I am trying out some sample Silverlight code with IronPython
>         and I found that the data binding does not work properly.
>         The app.xaml is as below:
>         <UserControl x:Class="System.Windows.Controls.UserControl"
>         xmlns="http://schemas.microsoft.com/client/2007"
>         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
>         <Grid x:Name="layout_root" Background="White">
>         <StackPanel>
>         <Slider x:Name="sliderFontSize" Margin="3" Minimum="1"
>         Maximum="40" Value="10" />
>         <TextBlock x:Name="lblMessage" Text="Hello World" Margin="5"
>         FontSize="{Binding ElementName=sliderFontSize,
>         Path=Value,Mode=TwoWay}"></TextBlock>
>         <Button x:Name="cmdClickMe" Content="Click Me!"
>         Margin="5"></Button>
>         </StackPanel>
>         </Grid>
>         </UserControl>
>         This XAML when used in a C# Silverlight app reflects the
>         correct data binding behaviour but does not work when used
>         with IronPython and Chiron. Mainly the font size of the text
>         block is not updated.
>         Does anyone have any idea about this?
>
>     Check my blog about binding in Silverlight:
>     http://gui-at.blogspot.com/2009/11/inotifypropertychanged-and-databinding.html
>
>     --
>     -- Lukáš
>
>
>     _______________________________________________
>     Users mailing list
>     Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>     http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20091231/50fa4684/attachment.htm>


More information about the Users mailing list