Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
745
Binding does not work
posted

Hi,

I've got a strange behavior regarding bindings. When I try to bind a property of a tool, for example the ButtonTool.Caption to my ViewModel, the binding never happens. (There are no binding errors listed in the Output window in VS). However, a binding does occur if I create my ViewModel as a resource and reference it using key throught StaticResource. Is this a bug? Why does the binding never occur?

So this piece of code "works";

<

UserControl x:Class="IGDialog.MainPage"
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:ig=infragistics.com/Controls
mc:Ignorable="d"
xmlns:local="clr-namespace:IGDialog"
d:DesignHeight="300" d:DesignWidth="400">

 

 

 

 

 

 

 

<UserControl.Resources>
   
<local:DataItem x:Key="DataItemHolder"/>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
    <ig:XamWebRibbon>
       <ig:XamWebRibbon.Tabs>
          <ig:XamWebRibbonTabItem Header="Tab1">
             <ig:XamWebRibbonGroup Caption="Group 1">
                  <ig:ButtonTool Caption="{Binding Path=MyCaption, Source={StaticResource DataItemHolder}}"> 
                  </ig:ButtonTool>
             </ig:XamWebRibbonGroup>
         </ig:XamWebRibbonTabItem>
       </ig:XamWebRibbon.Tabs>
    </ig:XamWebRibbon>
</Grid>
</
UserControl>

And this piece of code DOES NOT work;

<UserControl x:Class="IGDialog.MainPage"
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:ig=http://infragistics.com/Controls
mc:Ignorable="d"
xmlns:local="clr-namespace:IGDialog"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
    <ig:XamWebRibbon>
       <ig:XamWebRibbon.Tabs>
          <ig:XamWebRibbonTabItem Header="Tab1">
             <ig:XamWebRibbonGroup Caption="Group 1">
                  <ig:ButtonTool Caption="{Binding Path=MyCaption}"> 
                  </ig:ButtonTool>
             </ig:XamWebRibbonGroup>
         </ig:XamWebRibbonTabItem>
       </ig:XamWebRibbon.Tabs>
    </ig:XamWebRibbon>
</Grid>
</
UserControl>

public

 

 

MainPage()
{
    InitializeComponent();
    this.DataContext = new DataItem();
}

Thanks!