Click here to Skip to main content
15,892,059 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:21
professionalKevin Marois29-Apr-16 5:21 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:26
professionalKevin Marois29-Apr-16 5:26 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:43
professionalKevin Marois29-Apr-16 5:43 
QuestionSave And Restore Attached Property Values Pin
Kevin Marois27-Apr-16 11:53
professionalKevin Marois27-Apr-16 11:53 
AnswerRe: Save And Restore Attached Property Values Pin
Mycroft Holmes27-Apr-16 14:34
professionalMycroft Holmes27-Apr-16 14:34 
GeneralRe: Save And Restore Attached Property Values Pin
Kevin Marois28-Apr-16 6:47
professionalKevin Marois28-Apr-16 6:47 
AnswerRe: Save And Restore Attached Property Values Pin
Richard Deeming28-Apr-16 8:30
mveRichard Deeming28-Apr-16 8:30 
QuestionHow to have duplicate model/view-model in TabControl Pin
Leif Simon Goodwin21-Apr-16 2:01
Leif Simon Goodwin21-Apr-16 2:01 
I have a view which populates tab controls as follows:

<TabControl  x:Name="MyTabControl" ItemsSource="{Binding ViewModels}" Margin="4"
            Background="#DCE8F3"
            SelectedIndex="0"
            BorderBrush="LightGray"
            TabStripPlacement="Top">
    <TabControl.Resources>
        <DataTemplate DataType="{x:Type vm:SmartCardViewModel}">
            <view:SmartCardView/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type vm:RfidLogFileViewModel}">
            <view:LogFileView/>
        </DataTemplate>
        <DataTemplate DataType="{x:Type vm:VideoLogFileViewModel}">
            <view:LogFileView/>
        </DataTemplate>
    </TabControl.Resources>
    <TabControl.ItemTemplate>
        <DataTemplate>
        <TextBlock Text="{Binding Name}"/>
        </DataTemplate>
    </TabControl.ItemTemplate>
</TabControl>


The above has been simplified for clarity.

What I want is two instances of the LogFileViewModel and LogFileView pair in the tab, one for video files and one for RFID files. However, the above does not allow me to have the same model class twice, for reasons that are fairly obvious. I have got round this by deriving classes from LogFileViewModel, called VideoLogFileViewModel and RfidLogFileViewModel, which initialise the base class appropriately. The tab control obtains the view model instances from the ViewModels property of the main view model. Hence my workaround makes sure that there are no duplicate view model class instances. However, it is inelegant.

Is there some more elegant way of doing this?

I was wondering is there is some jiggery pokery I can add to the <datatemplate> to allow it to identify a specific instance of LogFileViewModel i.e. to compare a string property with a fixed value.
AnswerRe: How to have duplicate model/view-model in TabControl Pin
Pete O'Hanlon21-Apr-16 3:57
mvePete O'Hanlon21-Apr-16 3:57 
GeneralRe: How to have duplicate model/view-model in TabControl Pin
Leif Simon Goodwin22-Apr-16 0:41
Leif Simon Goodwin22-Apr-16 0:41 
GeneralRe: How to have duplicate model/view-model in TabControl Pin
Pete O'Hanlon22-Apr-16 0:44
mvePete O'Hanlon22-Apr-16 0:44 
QuestionWPF App for video recording from webcam into file MP4/h.264 Pin
Qinitram13-Apr-16 23:33
Qinitram13-Apr-16 23:33 
AnswerRe: WPF App for video recording from webcam into file MP4/h.264 Pin
Gerry Schmitz17-Apr-16 19:31
mveGerry Schmitz17-Apr-16 19:31 
QuestionUserControl not displayed inside the parent window only in designer Pin
hesido9-Apr-16 0:18
hesido9-Apr-16 0:18 
QuestionLoading resources from XAML, problem with fonts Pin
Jayme655-Apr-16 10:17
Jayme655-Apr-16 10:17 
AnswerRe: Loading resources from XAML, problem with fonts Pin
Pete O'Hanlon5-Apr-16 21:49
mvePete O'Hanlon5-Apr-16 21:49 
QuestionCombox with Multi Column Header Pin
fratola29-Mar-16 8:08
fratola29-Mar-16 8:08 
AnswerRe: Combox with Multi Column Header Pin
Richard Deeming29-Mar-16 8:26
mveRichard Deeming29-Mar-16 8:26 
GeneralRe: Combox with Multi Column Header Pin
fratola31-Mar-16 20:26
fratola31-Mar-16 20:26 
Questionlistviewitem style Pin
caradri13-Mar-16 0:41
caradri13-Mar-16 0:41 
Questionxceed datagrid (community) and virtualization Pin
amigoface9-Mar-16 18:47
amigoface9-Mar-16 18:47 
AnswerRe: window application form work in KIOSK Pin
Pete O'Hanlon8-Feb-16 21:37
mvePete O'Hanlon8-Feb-16 21:37 
AnswerRe: window application form work in KIOSK Pin
Richard Deeming9-Feb-16 1:55
mveRichard Deeming9-Feb-16 1:55 
AnswerRe: window application form work in KIOSK Pin
ZurdoDev9-Feb-16 8:36
professionalZurdoDev9-Feb-16 8:36 
QuestionHow to Programatically click a Button on a navigated Frame Page Pin
Vimalsoft(Pty) Ltd14-Jan-16 3:22
professionalVimalsoft(Pty) Ltd14-Jan-16 3:22 

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.