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 8580475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:50:20+00:00 2026-06-11T20:50:20+00:00

I have a Window that I’m showing using ShowDialog. One of the values I’m

  • 0

I have a Window that I’m showing using ShowDialog. One of the values I’m trying to get from the user is size in GB or TB. So I have two controls for this, an IntegerUpDown from the WPF Extended Toolkit and a ComboBox:

<xctk:IntegerUpDown Name="SizeN" Minimum="1" Maximum="1023" Increment="1" Value="100"/>
<ComboBox Name="SizeS" SelectedIndex="0">
    <ComboBoxItem>GB</ComboBoxItem>
    <ComboBoxItem>TB</ComboBoxItem>
</ComboBox>

I am setting the Dialog’s DataContext to itself. I have defined the Capacity property:

public ulong Capacity { get; set; }

public CustomWindow()
{
    InitializeComponent();
    DataContext = this;
}

I have already created an IMultiValueConverter, PowerConverter, that takes an int and a string and returns ulong. I think the correct MultiBinding is:

<Window.Resources>
    <local:PowerConverter x:Key="CapacityConverter" />
</Window.Resources>

<MultiBinding Converter="{StaticResource CapacityConverter}">
    <Binding ElementName="SizeN" Path="Value" />
    <Binding ElementName="SizeS" Path="SelectedValue" />
</MultiBinding>

I can’t figure out how to assign this binding to the Capacity property on the Dialog. I want WPF to automagically set the Capacity property for me. Any ideas?

  • 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-06-11T20:50:21+00:00Added an answer on June 11, 2026 at 8:50 pm

    I had to convert Capacity into a DependencyProperty on CustomWindow, set the SelectedValuePath attribute on the ComboBox, and assign the binding to Capacity in the style.

    XAML:

    <Window xmlns:="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"
            xmlns:local="clr-namespace:MyProject"
            x:Class="MyProject.CustomWindow" Title="CustomWindow"
            DataContext="{Binding RelativeSource={RelativeSource Self}}">
        <Window.Resources>
            <local:PowerConverter x:Key="CapacityConverter" />
        </Window.Resources>
        <Window.Style>
            <Style TargetType="{x:Type local:CustomWindow}">
                <Setter Property="Capacity">
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource CapacityConverter}"
                                      Mode="TwoWay">
                            <Binding  ElementName="SizeNumber" Path="Value"
                                      Mode="TwoWay" />
                            <Binding  ElementName="SizeSuffix" Path="SelectedValue"
                                      Mode="TwoWay" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Style>
        <StackPanel>
            <xctk:IntegerUpDown Name="SizeNumber" Minimum="1" Maximum="1023" Increment="1"
                                Value="100"/>                        
            <ComboBox Name="SizeSuffix" SelectedIndex="0" SelectedValuePath="Content">
                <ComboBoxItem>GB</ComboBoxItem>                        
                <ComboBoxItem>TB</ComboBoxItem>                        
            </ComboBox>
        </StackPanel>
    </Window>
    

    Code behind:

    public partial class CustomWindow : Window
    {
        public CustomWindow()
        {
            InitializeComponent();
        }
    
        public static readonly DependencyProperty CapacityProperty =
            DependencyProperty.Register("Capacity", typeof(ulong), typeof(CustomWindow));
    
        public ulong Capacity
        {
            get
            {
                return (ulong)GetValue(CapacityProperty);
            }
            set
            {
                SetValue(CapacityProperty, value);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a window that I sometimes open using Show() and sometimes using ShowDialog()
I have a Window that has two primary areas. One is a TextBox inside
I have a WPF window that is supposed to load two vector images from
I have a window that contains one QTMovieView. How do I make it so
I have a window that contains several rather complex views. Right now, I'm using
So I'm trying to have a window that I can drag around by the
I have a window that has two layers: a static background and a foreground
I have a window that displays text. There are two parts to the text:
I have a window that I'm building in code, and showing: Window wndViewer =
A have a KendoUI window that gets its content from a partial view. That

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.