Click here to Skip to main content
15,908,172 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Tarun.K.S20-Apr-11 3:59
Tarun.K.S20-Apr-11 3:59 
AnswerRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Ian Shlasko20-Apr-11 3:57
Ian Shlasko20-Apr-11 3:57 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Tarun.K.S20-Apr-11 4:09
Tarun.K.S20-Apr-11 4:09 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Ian Shlasko20-Apr-11 4:12
Ian Shlasko20-Apr-11 4:12 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Kunal Chowdhury «IN»20-Apr-11 22:44
professionalKunal Chowdhury «IN»20-Apr-11 22:44 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Rocky2327-Apr-11 19:49
Rocky2327-Apr-11 19:49 
GeneralRe: How to read the data from listbox Itemsource datatemplate and display it in UI controls Pin
Ian Shlasko28-Apr-11 1:41
Ian Shlasko28-Apr-11 1:41 
QuestionPulling controls from resources Pin
Jean-Louis Leroy19-Apr-11 2:51
Jean-Louis Leroy19-Apr-11 2:51 
Is it possible to put controls in app resources and use then as elements inside a StackPanel ?

A bit of context: I have a UserControl which I use like this:
<Window ...
    xmlns:local="clr-namespace:CRRT" ...>
  <local:QueryControl>
    <ScrollViewer>
      <StackPanel>
        <local:FeatureSelectionControl x:Key="GroupOwnerCRDSCode" Table="GroupOwnerCRDSCode" Label="Customer Group" Margin="12,12,18,9.999">
          <local:FeatureSelectionControl.SelectStatement>
            SELECT blablabla
          </local:FeatureSelectionControl.SelectStatement>
        </local:FeatureSelectionControl>
        <local:FeatureSelectionControl Table="RMPMCode" Label="RMPM Code">
          <local:FeatureSelectionControl.SelectStatement>
            select rarara
          </local:FeatureSelectionControl.SelectStatement>
        </local:FeatureSelectionControl>
        etc etc etc

Each local:FeatureSelectionControl fetches a list of values from a database and lets the user choose one of more values.

I will need to use the same FeatureSelectionControls (i.e. with the same Table/Label/SelectStatement combination) in a dozen of dialog boxes. Since the SQL may change I don't want to duplicate the elements all over. So I thought I'd put them in an application resource. But first let's try with a window resource:
<Window.Resources>
  <local:FeatureSelectionControl x:Key="GroupOwnerCRDSCode" Table="GroupOwnerCRDSCode" Label="Customer Group">
    <local:FeatureSelectionControl.SelectStatement>
      SELECT blablabla
    </local:FeatureSelectionControl.SelectStatement>
  </local:FeatureSelectionControl>
</Window.Resources>
Now how do I put the control in the StackPanel's collection of children ? IntelliSense didn't suggest a <staticresource> element but I still tried:
<ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Auto">
  <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
    <StaticResource ResourceKey="GroupOwnerCRDSCode" />
When I run it, I get a "first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll - Additional information: Stack empty.".

However, the preview in the Designer is just fine.

Does this approach has any chance of working ? What am I doing wrong ? If it works, will I get a single instance of a control (as identified by the same key) shared between my dialogs ? Or is a new instance created each time I pull from the resources ? What are the alternatives (I see one: put the three strings in resources, not the entire control).
AnswerRe: Pulling controls from resources Pin
Ian Shlasko19-Apr-11 5:56
Ian Shlasko19-Apr-11 5:56 
GeneralRe: Pulling controls from resources Pin
Jean-Louis Leroy19-Apr-11 23:00
Jean-Louis Leroy19-Apr-11 23:00 
GeneralRe: Pulling controls from resources Pin
Ian Shlasko20-Apr-11 2:40
Ian Shlasko20-Apr-11 2:40 
GeneralRe: Pulling controls from resources Pin
Jean-Louis Leroy20-Apr-11 3:00
Jean-Louis Leroy20-Apr-11 3:00 
QuestionHow To Create This Menu In WPF Pin
Kevin Marois18-Apr-11 10:49
professionalKevin Marois18-Apr-11 10:49 
AnswerRe: How To Create This Menu In WPF Pin
Pete O'Hanlon18-Apr-11 11:20
mvePete O'Hanlon18-Apr-11 11:20 
GeneralRe: How To Create This Menu In WPF Pin
Kevin Marois18-Apr-11 11:26
professionalKevin Marois18-Apr-11 11:26 
GeneralRe: How To Create This Menu In WPF Pin
Pete O'Hanlon18-Apr-11 11:31
mvePete O'Hanlon18-Apr-11 11:31 
GeneralRe: How To Create This Menu In WPF Pin
Kevin Marois19-Apr-11 5:22
professionalKevin Marois19-Apr-11 5:22 
GeneralRe: How To Create This Menu In WPF Pin
Pete O'Hanlon19-Apr-11 6:37
mvePete O'Hanlon19-Apr-11 6:37 
QuestionAnybody got TaskbarItemProgressState.Indeterminate to work? Pin
SledgeHammer0118-Apr-11 6:55
SledgeHammer0118-Apr-11 6:55 
AnswerRe: Anybody got TaskbarItemProgressState.Indeterminate to work? Pin
KevinAG6-Mar-19 6:14
KevinAG6-Mar-19 6:14 
QuestionProblem with this binding... Pin
SledgeHammer0118-Apr-11 6:49
SledgeHammer0118-Apr-11 6:49 
AnswerRe: Problem with this binding... Pin
Adrian Cole18-Apr-11 11:03
Adrian Cole18-Apr-11 11:03 
GeneralRe: Problem with this binding... Pin
SledgeHammer0118-Apr-11 11:55
SledgeHammer0118-Apr-11 11:55 
QuestionResource dictionary [modified] Pin
CrafterIt18-Apr-11 4:36
CrafterIt18-Apr-11 4:36 
AnswerRe: Resource dictionary Pin
Kunal Chowdhury «IN»20-Apr-11 22:37
professionalKunal Chowdhury «IN»20-Apr-11 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.