Home > DeveloperSection > Forums > How to change datatemplate through code
lois waisbrooker
lois waisbrooker

Total Post:70

Points:494
Posted on    August-16-2013 5:56 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 844  View(s)
Rate this:
Hi!

I have ListBox and DataTemplate

I need Set GroupBox Heigth = 300

How to do it?

<DataTemplate x:Key="data_template">

    <GroupBox Header="Категория" Width="300"  HorizontalAlignment="Stretch" x:Name="GroupBox">

    <DockPanel Tag="{Binding id}">

        <Button Click="Button_Click" DockPanel.Dock="Top" >

        <Button.Content>

            <DockPanel>

            <TextBlock Text="{Binding title}" TextWrapping="Wrap" DockPanel.Dock="Top" Padding="5"  HorizontalAlignment="Center"  Foreground="#FFB51414" />

            <l:ScrollViewerEx  VerticalScrollBarVisibility="Auto" >

                <TextBlock Text="{Binding description}" DockPanel.Dock="Top" TextWrapping="Wrap" Padding="5" IsHitTestVisible="False" />

            </l:ScrollViewerEx>

            </DockPanel>

        </Button.Content>

        </Button>

    </DockPanel>

    </GroupBox>

</DataTemplate>

Thanks in Advance



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    August-17-2013 7:04 AM

Hi!

In case, someone tried to resolve my previous question, I did it like the following:

DataTemplate mycolumnDataTemplate = null;

var dataTemplateStream = new SomeClass().GetType().Assembly.GetManifestResourceStream("Some.Namespace.SomeReosurceName.xaml");

string dataTemplateString = new System.IO.StreamReader(dataTemplateStream).ReadToEnd();

dataTemplateString = dataTemplateString.Replace("[0]", browserColumn.ColumnName);

mycolumnDataTemplate = XamlReader.Load(dataTemplateString) as DataTemplate;

thanks



Don't want to miss updates? Please click the below button!

Follow MindStick