开发者

Silverlight DataTemplate "Name", how to use in codebehind?

In the following XAML, how can I use _xyzStackPanel in the code behind? Is this not possible when we use DataTemplate? I need to show/hide this stackpanel, what is the best way?

Can I use the VisualStateManager here? Could someone provide example please, thanks.

<ListBox  ... >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Name="_xyzStackPanel" ...>开发者_开发百科
            ..............
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Thanks,

Voodoo

EDIT:

I wonder if it would be better to add the StackPanel in the codebehind instead of always having it there and hiding it......BUT, how can I add to the DataTemplate in the codebehind?


Bind the Visibility of the StackPanel to the ViewModel object it represents and toggle that instead. You are using MVVM, right??

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜