Hello,
I have a problem with binding in NavBarControl.
Next code is correct and it works
<Window …>
<Grid>
<ContentControl Width="30">
<Line X1="0" Y1="0.5" X2="1" Y2="0.5" Stretch="Fill" Stroke="Black"
StrokeThickness="{Binding ElementName=sliderLineSize, Path=Value}"></Line>
</ContentControl>
<Slider MinWidth="30" Name="sliderLineSize" TickPlacement="TopLeft" Minimum="1" TickFrequency="1" Maximum="25" Margin="5, 0, 5, 0" Value="1"></Slider>
</Grid>
</Window>
Thickness of the line is binding to the value of the slider. But next code doesnt work:
…
<dxn:NavBarControl Width="300" Height="Auto">
<dxn:NavBarControl.Groups>
<dxn:NavBarGroup Header="xxx" GroupStyle="ContainerControl">
<dxn:NavBarGroup.Content>
<Grid>
<ContentControl Width="40">
<Line Name="linePreview" X1="0" Y1="0.5" X2="1" Y2="0.5" Stretch="Fill" Stroke="Black"
StrokeThickness="{Binding ElementName=sliderLineSize, Path=Value}"></Line>
</ContentControl>
<Slider MinWidth="30" Name="sliderLineSize" TickPlacement="TopLeft" Minimum="1"
TickFrequency="1" Maximum="25" Margin="5, 0, 5, 0"
Value="1" ValueChanged="sliderLineSize_ValueChanged"></Slider>
</Grid>
</dxn:NavBarGroup.Content>
</dxn:NavBarGroup>
</dxn:NavBarControl.Groups>
<dxn:NavBarControl.View>
<dxn:NavigationPaneView>
</dxn:NavigationPaneView>
</dxn:NavBarControl.View>
</dxn:NavBarControl>
…
Programm runs as usually, but Line doesnt binds to slider. In output there is next message:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=sliderLineSize'. BindingExpression:Path=Value; DataItem=null; target element is 'Line' (Name='linePreview'); target property is 'StrokeThickness' (type 'Double')
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Aleksandr,
This seems to be a flaw in our control. Thank you for drawing our attention to it. I've converted your Question to a Bug Report and we'll do our best to resolve it as soon as possible.
Thanks,
Serge
P.S. While testing this issue, we've found another problem. So, I've created a separate Bug Report on your behalf - ContentTemplate isn't applied to a NavBarGroup.
For now, please use the following workaround:
<dxn:NavBarControl> <dxn:NavBarControl.Groups> <dxn:NavBarGroup GroupStyle="ContainerControl"> <dxn:NavBarGroup.Content> <ContentControl> <ContentControl.ContentTemplate> <DataTemplate> <Grid> <ContentControl Width="40"> <Line Name="linePreview" X1="0" Y1="0.5" X2="1" Y2="0.5" Stretch="Fill" Stroke="Black" StrokeThickness="{Binding ElementName=sliderLineSize, Path=Value}"/> </ContentControl> <Slider MinWidth="30" Name="sliderLineSize" TickPlacement="TopLeft" Minimum="1" TickFrequency="1" Maximum="25" Margin="5, 0, 5, 0" Value="1"/> </Grid> </DataTemplate> </ContentControl.ContentTemplate> </ContentControl> </dxn:NavBarGroup.Content> </dxn:NavBarGroup> </dxn:NavBarControl.Groups> <dxn:NavBarControl.View> <dxn:NavigationPaneView/> </dxn:NavBarControl.View> </dxn:NavBarControl>
Regards,
Serge
SEE ALSO:
Data Binding - Wrong DataContext of items in a NavBarGroup