c# - Dynamically add TextBlock to StackPanel -


Then I am developing a Windows Phone 8 app in C # using MVVM pattern. I have a screen where the layout should be like this:

  • Text Block
  • Image
  • Text Block
  • Text Block
  • If there is a dynamic list of buttons, then 1> enter a text block
  • Dynamic list of buttons
  • Text block
  • Text block
  • < / Ul>

    So I'm trying to set it up in the xaml code, and it looks like:

      & lt; StackPanel Orientation = "Vertical" & gt; & Lt; TextBlock margin = "20,0,20,0" TextWrapping = "wrap" foreground = "# c8d75a" text = "{binding title, mode = double}" height = "46" & gt; & Lt; / TextBlock & gt; & Lt; Image margin = "20,0,20,0" source = "{binding image link}" height = "200" & gt; & Lt; / Image & gt; & Lt; TextBlock margin = "20,0,20,0" textwapping = "wrap" foreground = "# 7e9d83" text = "{binding sub-title, mode = two}" height = "46" & gt; & Lt; / TextBlock & gt; & Lt; TextBlock margin = "20,0,20,0" TextWrapping = "wrap" foreground = "# 7e9d83" text = "{binding description, mode = two}" height = "46" & gt; & Lt; / TextBlock & gt; & Lt; Itemcontrol items source = "{binding related links}" & gt; & Lt; ItemsControl.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text block margin = "20,0,20,0" foreground = "# c8d75a" text = "{binding text, mode = two}" height = "46" & gt; & Lt; I: Interaction.Triggers & gt; & Lt; I: Event Trigger Event Name = "Tap" & gt; & Lt; Cm: Action Message Alias ​​= "Open Linked" & gt; & Lt; Cm: Parameter value = "{binding href}" & gt; & Lt; / Cm: Parameters & gt; & Lt; / Cm: ActionMessage & gt; & Lt; / I: EventTrigger & gt; & Lt; / I: Interaction.Triggers & gt; & Lt; / TextBlock & gt; & Lt; / DataTemplate & gt; & Lt; /ItemsControl.ItemTemplate> & Lt; / ItemsControl> & Lt; TextBlock margin = "20,0,20,0" TextWrapping = "wrap" foreground = "# 7e9d83" text = "{binding creator, mode = twi}" height = "46" & gt; & Lt; / TextBlock & gt; & Lt; TextBlock margin = "20,0,20,0" TextWrapping = "wrap" foreground = "# 7e9d83" text = "{binding pubadet, mode = two}" height = "46" & gt; & Lt; / TextBlock & gt;  

    .

    Let me try to explain further. My {binding related links} is a bind for observation. Select ; Related links & gt; where related links is an object with two strings Href and text .

    then If the selection of related links is big about my observation, then 1 I have to keep a title text above this item control list. How can I get it?

    observation code implies INotifyPropertyChanged and < Informs about changes in code> Calculation , so that you can tie it to show or hide text block , you can change it to its visibility Are:

      & lt; TextBlock visibility = "{related links:, converter = {static resource counttivility कनવર}}" ... ... & gt;  

    What is left to write the specialty conveyor count and add to the resources. Its convert method will do something like this:

      Public Object Convert (Object Value, Type Target Type, Object Parameter, CultureInfo Culture) {Return Value >> & gt; 1? Visibility View: visibility. Collapsed; }  

    There will be an alternative approach to adding a property bool textvisible to your view modal and whenever you update the Observe Collection, a standard BoolToVisibilityConverter Use


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -