Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6977155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:35:22+00:00 2026-05-27T17:35:22+00:00

This question is a follow-up to one I asked and got answered here: How

  • 0

This question is a follow-up to one I asked and got answered here: How to display XPS document using a selected combobox item

I’ve created a WPF app using VB 2010. I set the comboboxitems via the XAML. However, I can’t seem to figure out how to set the value of each item to a file path.

The objective is for a user to be able to select an item from a drop-down list, then that selection opens an XPS file in the DocumentViewer. The code below was provided to me by COMPETENT_TECH (thanks) to read and display the value of the selected comboboxitem in the DocumentViewer.

The path to the files I want opened is C:\folder\file.xps

Private Sub Button4_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button4.Click

    Try
        Dim sFileName As String

        sFileName = DirectCast(ComboBox1.SelectedValue, String)
        If Not String.IsNullOrEmpty(sFileName) Then
            Dim theDocument As New System.Windows.Xps.Packaging.XpsDocument(sFileName, System.IO.FileAccess.Read)

            DocumentViewer1.Document = theDocument.GetFixedDocumentSequence()
        End If
    Catch ex As Exception
        MessageBox.Show("ERROR: " & ex.Message)
    End Try


End Sub

Thanks in advance for your assistance.

Update

Here’s the XAML I’m using:

<ComboBox Width="Auto" IsReadOnly="True" IsEditable="True" Name="ComboBox1" Height="Auto" Margin="0" Padding="1" Grid.Column="2"> 
  <ComboBoxItem>123456</ComboBoxItem> 
  <ComboBoxItem>123457</ComboBoxItem> 
  <ComboBoxItem>123458</ComboBoxItem> 
</ComboBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:35:23+00:00Added an answer on May 27, 2026 at 5:35 pm

    Depending on precisely how the xaml to load the combobox is specified, you will probably want to change this line:

    Dim theDocument As New System.Windows.Xps.Packaging.XpsDocument(sFileName, System.IO.FileAccess.Read)
    

    to:

    Dim theDocument As New System.Windows.Xps.Packaging.XpsDocument(System.IO.Path.Combine("C:\folder", sFileName & ".xps"), System.IO.FileAccess.Read)
    

    All that we do in the new code is combine the directory where the files are stored with the file name retrieved from the combobox.

    Update

    The correct way to retrieve the value from the combobox is:

    If ComboBox1.SelectedValue IsNot Nothing Then
        sFileName = DirectCast(ComboBox1.SelectedValue, ComboBoxItem).Content.ToString()
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-on question from the one I asked here . Can constraints
This question is a follow on from the one that was asked here .
Just a follow up question to this one here => link Is it possible
(This is sort of a follow up question to one I asked before )
As a follow up question to this one I asked yesterday , are there
This question would be a follow up from the one asked Content Resolver vs
This question is a follow on from this one ... I am binding to
This is a follow-up question to this one . Consider this example: #include <iostream>
This is like a follow-up question to this one . Basically what I'm doing
I have a follow-up question to this one . I created a new form,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.